fix(Facebook Graph API Node): Route failed items to the error output#32027
fix(Facebook Graph API Node): Route failed items to the error output#32027hammadxcm wants to merge 1 commit into
Conversation
When 'Continue (using error output)' is selected, the node pushed the
errored item into the main output without an 'error' or 'pairedItem'
property. The execution engine only routes an item to the error output
when it carries 'error' (or a json shaped like { error } / { error,
message }), so failed requests were emitted on the success path instead.
Attach a NodeApiError (for failed requests) or NodeOperationError (for
non-JSON string responses) together with pairedItem to the pushed items,
so the engine routes them to the error output while still preserving the
Graph API error detail on the item.
There was a problem hiding this comment.
No issues found across 2 files
Architecture diagram
sequenceDiagram
participant Engine as Workflow Execution Engine
participant Node as Facebook Graph API Node
participant HTTP as Graph API (HTTPS)
participant ErrorHandler as Engine Error Output Handler
Note over Engine,ErrorHandler: Error output routing for continueOnFail
Engine->>Node: execute() with continueOnFail=true
Node->>HTTP: GET /v23.0/123456/feed
alt Request succeeds
HTTP-->>Node: JSON response
Node->>Node: Parse JSON
Node-->>Engine: { json: responseData }
Engine->>Engine: Route to success output
else Request fails (e.g. 401, 400)
HTTP-->>Node: Error response (statusCode, body)
Node->>Node: Catch error, build errorItem
Node->>Node: Create NodeApiError with error detail
Node->>Node: Attach error + pairedItem to item
Node-->>Engine: { json: errorItem, error: NodeApiError, pairedItem }
Engine->>ErrorHandler: handleNodeErrorOutput()
ErrorHandler->>ErrorHandler: Detect error property on item
ErrorHandler-->>Engine: Route item to error output
else Response is non-JSON string
HTTP-->>Node: HTML/plain text response
Node->>Node: Detect non-JSON string
Node->>Node: Create NodeOperationError
Node->>Node: Attach error + pairedItem to item
Node-->>Engine: { json: { message: response }, error, pairedItem }
Engine->>ErrorHandler: Route to error output
end
alt continueOnFail=false
Node->>Node: Throw error directly
Node-->>Engine: Rejected promise
Engine->>Engine: Standard error propagation
end
|
Hey @hammadxcm, Thank you for your contribution. We appreciate the time and effort you’ve taken to submit this pull request. Before we can proceed, please ensure the following: Regarding new nodes: If your node integrates with an AI service that you own or represent, please email nodes@n8n.io and we will be happy to discuss the best approach. About review timelines: Thank you again for contributing to n8n. |
Summary
When Continue (using error output) is selected on the Facebook Graph API node, failed requests were still emitted on the success output instead of the error output.
continueOnFail()was handled, but the errored item was pushed into the main output without anerrororpairedItemproperty:The execution engine (
WorkflowExecute.handleNodeErrorOutput) only moves an item to the error output when it carriesitem.error— or ajsonshaped exactly like{ error }/{ error, message }— and usespairedItemto resolve the originating input item. The Graph API node's error item is a flat object with several keys and nopairedItem, so it was never recognized as an error and stayed on the success path.This PR attaches the error and
pairedItemto the pushed items, following the established node convention (e.g. the JWT node):NodeApiErrorNodeOperationErrorThe existing Graph API error detail is still preserved on the item's
json, so the behavior of the regular Continue mode is unchanged.How to test
Unit tests cover: throwing when
continueOnFailis off, routing a failed request to the error output (item haserror+pairedItem, Graph detail preserved), and treating a non-JSON string response as an error item.Related Linear tickets, Github issues, and Community forum posts
Fixes #31699
Review / Merge checklist