All articles

Platform

Salesforce Flow error handling: the fault path, and the log that survives a rollback

When a flow element fails, the whole transaction rolls back and the user sees a generic error you can't debug. A fault path changes that, but the log you write inside it can vanish in the same rollback. How fault connectors work, when Custom Error beats them, and the platform-event pattern that makes a failure record stick.

A record-triggered flow with no fault paths is a flow that fails silently. The Update element hits a validation rule, the transaction rolls back, and the user sees “An error occurred while trying to update the record.” Nothing tells you which element threw, or why.

You find out when someone files a ticket a week later. By then the trace is gone.

My rule is simple. Put a fault connector on every element that can fail, and write the error somewhere that survives the rollback.

The second half is where most teams slip. The obvious move, creating a log record on the fault path, puts the log in the same transaction that is about to roll back and take the log with it. The durable fix is a platform event. Below is how both halves work, and the order I build them in.

What happens when you skip the fault path

A flow runs inside a single database transaction. When an element fails and no fault connector leaves it, Salesforce stops the flow, rolls back every uncommitted change in that transaction, and shows the running user an unhelpful error.

For a screen flow that’s a default error screen. For a record-triggered or autolaunched flow it’s the generic system message on the page.

The rollback is the part people underestimate. The failed element isn’t the only thing that reverts. Everything the flow did up to that point reverts too, along with anything else in the same transaction. Update three records, fail on the fourth, and all four are gone.

For data integrity that’s usually right. For visibility it’s always wrong, because the rollback erases the evidence along with the change.

Which elements can even fail? The ones that touch the database or the outside world: Get Records, Create / Update / Delete Records, Action elements, and Subflow calls. Salesforce’s documentation is explicit that those are where a fault connector belongs. Assignment and Decision elements make no callouts or DML, so they don’t get one.

The fault connector, and the thing it changes

Drag a fault connector off a DML or Action element and you create a second path the flow follows only when that element throws. On that path you decide what happens instead of the default rollback-and-generic-error.

There’s a behavior change here that surprises people. In a record-triggered flow that runs after save, adding a fault path to an element means the triggering record can still be saved even though the flow failed. Without the fault path, the error blocks the whole save. With it, the flow catches the error, runs your fault branch, and the original save commits. Trailhead is clear on this: a fault path lets the triggering change through.

For a non-critical side effect, that’s what you want. For an element that was the whole point of the flow, it’s a data-loss bug. You caught the error only to log it, and let the record save without the thing it needed.

So the first design question for every fault path isn’t “how do I log this.” The question is whether the record should have saved at all once that element failed. Decide that before you write the logging.

Capture the real error with $Flow.FaultMessage

The reason to build fault paths is to keep the system’s error text. Salesforce exposes it in a global variable, $Flow.FaultMessage, available on any fault path. It holds the actual error the failed element produced: the validation rule’s message, the DML exception, the Apex error from an invoked action.

The minimum useful fault path captures three things: the fault message, the flow’s API name, and the Id of the record being processed. Salesforce’s own fault examples show the pattern with a case. On the fault path, create a Case whose description is set to $Flow.FaultMessage and route it to IT.

That works as a demo. In production you don’t want a Case per failure. You want a structured log row and an alert, built in one place.

Build a single autolaunched subflow, call it Log_Flow_Error, that takes three inputs: the fault message, the flow name, and the record Id. Every fault path in every flow calls that one subflow. When you want to change how errors are logged, you change it once. It’s the same discipline as one trigger handler per object: the logic lives in exactly one place, and the flows that call it stay readable.

The rollback trap, and why your log disappears

The mistake that makes people distrust fault paths looks like this. You build the Log_Flow_Error subflow, it creates a Flow_Error__c record, you test it, the log appears. Then in production the logs are missing exactly when you need them.

The cause is the transaction boundary. A fault path runs in the same transaction as the element that failed. If your fault path creates a log record and the flow then ends cleanly, the log commits.

But if anything later in that transaction throws an unhandled error, or the flow ends in a way that rolls the transaction back, your log record rolls back with everything else. The failures that roll back the whole transaction are exactly the ones you most need a record of. Those are the ones an in-transaction log can’t capture.

The Custom Error element makes the shape obvious. Custom Error, and its screen-flow sibling Roll Back Records, exists to intentionally roll back the current transaction and show a designed message. If your fault path logs to a Flow_Error__c record and then hits a Custom Error, the log never persists. The rollback is doing its job. Your logging just assumed a commit that never came.

Publish a platform event, because it can’t be rolled back

The durable fix is to log through a platform event instead of a regular DML insert.

A platform event set to the Publish Immediately behavior is published the moment the flow reaches the publish step, whether or not the surrounding transaction later commits. Salesforce states it directly: once a message is published this way, you can’t roll it back, and the savepoint and rollback methods don’t apply to it.

The alternative, Publish After Commit, holds the event until the transaction commits and never fires it if the transaction fails. That’s the opposite of what error logging needs.

So the pattern is two hops. The flow’s fault path publishes a Flow_Error_Event__e platform event carrying the fault message, flow name, and record Id. A separate subscriber writes the Flow_Error__c row in its own transaction. The failing transaction rolls back, the event survives, and the subscriber commits the log a moment later.

// Apex subscriber on the platform event, runs in its own transaction,
// so the log persists even when the original flow transaction rolled back.
trigger FlowErrorEventTrigger on Flow_Error_Event__e (after insert) {
    List<Flow_Error__c> logs = new List<Flow_Error__c>();
    for (Flow_Error_Event__e evt : Trigger.new) {
        logs.add(new Flow_Error__c(
            Flow_Name__c     = evt.Flow_Name__c,
            Fault_Message__c = evt.Fault_Message__c,
            Record_Id__c     = evt.Record_Id__c,
            Logged_At__c     = System.now()
        ));
    }
    insert logs;
}

To stay no-code, replace the Apex trigger with a platform-event-triggered flow that does the same insert. Either way the subscriber runs after the fact, in a fresh transaction, so the rollback of the original flow can’t reach it.

Platform events are the same primitive behind a lot of durable Salesforce integration. The Pub/Sub API streams these events to external systems too, if you want the errors in your own observability stack.

Who finds out, and how

Logging is half of error handling. Someone has to be told.

By default, when a flow fails Salesforce emails the user who last modified it, with the error and a step-by-step of how the interview ran. That default is wrong for most orgs. The last person to touch the flow in a sandbox is rarely the person who should field production alerts.

Change the recipient under Setup, in Process Automation Settings, in the “Send Process or Flow Error Email” field. Switching it to the Apex Exception Email recipients routes flow errors to where your Apex exceptions already go, which is usually where your monitoring lives. The side effect: those recipients then receive both flow and Apex exception emails. For a team already triaging Apex exceptions, that consolidation is the point.

For anything higher-volume, don’t rely on email. The platform-event subscriber that writes your log is the natural place to raise a real alert: a custom notification to an ops queue, a post to a monitoring channel, a counter you can report on. An email per failure is noise. A dashboard of Flow_Error__c grouped by flow name is a signal.

Where fault paths stop

Fault paths aren’t the whole story, and two boundaries matter.

Before-save record-triggered flows are the first. They run before the record is written and are limited to fast field updates on the triggering record, with no DML on other records and no Action callouts. Very little in one can throw a catchable fault, and almost nothing is there to log. To block a bad save with a message, use a Custom Error element or a validation rule, not a fault path.

Keep before-save flows for the field updates they’re built for. Put the failure-prone work in after-save or autolaunched flows, where fault connectors belong. The full order of execution is worth reading once so you know which flow runs where.

The scheduled path is the second. A record-triggered flow’s scheduled path runs asynchronously, hours later, with no user watching. A fault there can’t show anyone an error screen, so the platform-event log is the only way you’ll know the scheduled work failed. Build those with logging first and the happy path second.

Test the fault path, not just the happy path

A fault path you never exercised is a guess. Winter ‘27’s Flow Builder Test Mode runs a flow against real or specified records without committing, which walks the happy path fast. Forcing a fault takes a bit more.

The reliable way to trigger one is to point an element at a condition you know will fail: a Get whose filter returns nothing feeding a later element that assumes a result, or an Update a validation rule will reject. Run it, confirm the fault branch fires, confirm the event published, and confirm the Flow_Error__c row exists after the rollback. If the row is there, your logging survives the case that matters.

It’s the same discipline that makes an AI-drafted flow safe to ship. Ask Agentforce for Flow to build a flow and it drafts the happy path, skipping the fault handling unless you specify it, which is the most common defect in hand-built flows too.

And when an Agentforce action is built from a Flow, that flow runs the same error handling as any other. A fault that isn’t caught and logged becomes an agent that fails without telling anyone why.

What I’d do first

If your org has production flows with no fault paths, you don’t need a project. You need an order of operations.

Build the Flow_Error_Event__e platform event and the subscriber that logs it. Build the one Log_Flow_Error subflow that publishes the event. Then add a fault connector to the highest-risk element in your busiest flow, point it at the subflow, and force a failure to prove the log lands.

Once that loop works end to end, rolling it out to the rest is mechanical. The hard part was never the fault connector. It was making sure the record of the failure outlives the failure.

Understanding the basics

What is a fault path in Salesforce Flow?

A fault path is a second connector you add to an element that can fail, such as a Get, a Create/Update/Delete, an Action, or a Subflow. When that element throws at run time, the flow follows the fault path instead of stopping with the default error, so you can capture $Flow.FaultMessage, log it, and decide whether the record should still save.

Why do my Flow error logs disappear?

Because they were created in the same transaction that rolled back. A log record you insert on a fault path is rolled back along with everything else when the transaction fails. The fix is to publish a platform event with the Publish Immediately behavior, which can’t be rolled back, and let a separate subscriber write the log in its own transaction.

What’s the difference between a fault path and the Custom Error element?

A fault path handles an error an element throws, so the flow can recover or log instead of failing hard. The Custom Error element deliberately causes a failure: it rolls back the current transaction and shows a message you wrote, which is the record-triggered-flow way to block a bad save. Screen flows use Roll Back Records for the same intentional rollback.

Who gets the error email when a Flow fails?

By default, Salesforce emails the user who last modified the flow. You change the recipient in Setup under Process Automation Settings, in the “Send Process or Flow Error Email” field, commonly switching it to the Apex Exception Email recipients so errors land with your existing monitoring. Those recipients then also receive Apex exception emails.


Getting flows to fail loudly instead of silently is the kind of reliability work that pays for itself the first time a production job breaks. If your org is carrying flows with no error handling and no idea what’s failing, talk to us. Building the logging layer once is cheaper than debugging blind every time.

Keep reading

All articles