Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Do not show errors not processed by n8n (no-changelog) #9598

Merged
merged 10 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export async function conversationalAgentExecute(
} catch (error) {
throwIfToolSchema(this, error);

if (this.continueOnFail()) {
if (this.continueOnFail(error)) {
returnData.push({ json: { error: error.message }, pairedItem: { item: itemIndex } });
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export async function openAiFunctionsAgentExecute(

returnData.push({ json: response });
} catch (error) {
if (this.continueOnFail()) {
if (this.continueOnFail(error)) {
returnData.push({ json: { error: error.message }, pairedItem: { item: itemIndex } });
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export async function planAndExecuteAgentExecute(
returnData.push({ json: response });
} catch (error) {
throwIfToolSchema(this, error);
if (this.continueOnFail()) {
if (this.continueOnFail(error)) {
returnData.push({ json: { error: error.message }, pairedItem: { item: itemIndex } });
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export async function reActAgentAgentExecute(
returnData.push({ json: response });
} catch (error) {
throwIfToolSchema(this, error);
if (this.continueOnFail()) {
if (this.continueOnFail(error)) {
returnData.push({ json: { error: error.message }, pairedItem: { item: itemIndex } });
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export async function sqlAgentAgentExecute(

returnData.push({ json: response });
} catch (error) {
if (this.continueOnFail()) {
if (this.continueOnFail(error)) {
returnData.push({ json: { error: error.message }, pairedItem: { item: i } });
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,8 @@ export async function toolsAgentExecute(this: IExecuteFunctions): Promise<INodeE
),
});
} catch (error) {
if (this.continueOnFail()) {
returnData.push({
json: { error: error?.message },
pairedItem: { item: itemIndex },
});
if (this.continueOnFail(error)) {
returnData.push({ json: { error: error.message }, pairedItem: { item: itemIndex } });
continue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ export class OpenAiAssistant implements INodeType {

returnData.push({ json: response });
} catch (error) {
if (this.continueOnFail()) {
if (this.continueOnFail(error)) {
returnData.push({ json: { error: error.message }, pairedItem: { item: itemIndex } });
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ export class ChainLlm implements INodeType {
});
});
} catch (error) {
if (this.continueOnFail()) {
if (this.continueOnFail(error)) {
returnData.push({ json: { error: error.message }, pairedItem: { item: itemIndex } });
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ export class ChainRetrievalQa implements INodeType {
const response = await chain.withConfig(getTracingConfig(this)).invoke({ query });
returnData.push({ json: { response } });
} catch (error) {
if (this.continueOnFail()) {
if (this.continueOnFail(error)) {
returnData.push({ json: { error: error.message }, pairedItem: { item: itemIndex } });
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ export class ChainSummarizationV2 implements INodeType {
returnData.push({ json: { response } });
}
} catch (error) {
if (this.continueOnFail()) {
if (this.continueOnFail(error)) {
returnData.push({ json: { error: error.message }, pairedItem: { item: itemIndex } });
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/@n8n/nodes-langchain/nodes/code/Code.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ export class Code implements INodeType {
try {
items = await sandbox.runCodeAllItems(options);
} catch (error) {
if (!this.continueOnFail()) throw error;
if (!this.continueOnFail(error)) throw error;
items = [{ json: { error: (error as Error).message } }];
if (options.multiOutput) {
items = [items];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export async function router(this: IExecuteFunctions) {

returnData.push(...responseData);
} catch (error) {
if (this.continueOnFail()) {
if (this.continueOnFail(error)) {
returnData.push({ json: { error: error.message }, pairedItem: { item: i } });
continue;
}
Expand Down
9 changes: 8 additions & 1 deletion packages/core/src/NodeExecuteFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ import {
jsonParse,
ApplicationError,
sleep,
OBFUSCATED_ERROR_MESSAGE,
} from 'n8n-workflow';
import type { Token } from 'oauth-1.0a';
import clientOAuth1 from 'oauth-1.0a';
Expand Down Expand Up @@ -3583,7 +3584,13 @@ export function getExecuteFunctions(
itemIndex,
),
getExecuteData: () => executeData,
continueOnFail: () => continueOnFail(node),
continueOnFail: (error?: Error) => {
const shouldContinue = continueOnFail(node);
if (error && shouldContinue && !(error instanceof ApplicationError)) {
error.message = OBFUSCATED_ERROR_MESSAGE;
}
return shouldContinue;
},
evaluateExpression: (expression: string, itemIndex: number) => {
return workflow.expression.resolveSimpleParameterValue(
`=${expression}`,
Expand Down
10 changes: 5 additions & 5 deletions packages/core/src/WorkflowExecute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import {
ApplicationError,
NodeExecutionOutput,
sleep,
OBFUSCATED_ERROR_MESSAGE,
} from 'n8n-workflow';
import get from 'lodash/get';
import * as NodeExecuteFunctions from './NodeExecuteFunctions';
Expand Down Expand Up @@ -1304,13 +1305,12 @@ export class WorkflowExecute {
} catch (error) {
this.runExecutionData.resultData.lastNodeExecuted = executionData.node.name;

const message =
error instanceof ApplicationError ? error.message : OBFUSCATED_ERROR_MESSAGE;

const e = error as unknown as ExecutionBaseError;

executionError = {
...e,
message: e.message,
stack: e.stack,
};
executionError = { ...e, message, stack: e.stack };

Logger.debug(`Running node "${executionNode.name}" finished with error`, {
node: executionNode.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ export class ActionNetwork implements INodeType {
? returnData.push(...(response as IDataObject[]))
: returnData.push(response as IDataObject);
} catch (error) {
if (this.continueOnFail()) {
if (this.continueOnFail(error)) {
returnData.push({ error: error.message });
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1190,7 +1190,7 @@ export class ActiveCampaign implements INodeType {

returnData.push(...executionData);
} catch (error) {
if (this.continueOnFail()) {
if (this.continueOnFail(error)) {
const executionErrorData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray({ error: error.message }),
{ itemData: { item: i } },
Expand Down
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/Affinity/Affinity.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ export class Affinity implements INodeType {

returnData.push(...executionData);
} catch (error) {
if (this.continueOnFail()) {
if (this.continueOnFail(error)) {
const executionErrorData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray({ error: error.message }),
{ itemData: { item: i } },
Expand Down
10 changes: 5 additions & 5 deletions packages/nodes-base/nodes/Airtable/v1/AirtableV1.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ export class AirtableV1 implements INodeType {
rows.length = 0;
}
} catch (error) {
if (this.continueOnFail()) {
if (this.continueOnFail(error)) {
returnData.push({ json: { error: error.message } });
continue;
}
Expand Down Expand Up @@ -696,7 +696,7 @@ export class AirtableV1 implements INodeType {
rows.length = 0;
}
} catch (error) {
if (this.continueOnFail()) {
if (this.continueOnFail(error)) {
returnData.push({ json: { error: error.message } });
continue;
}
Expand Down Expand Up @@ -757,7 +757,7 @@ export class AirtableV1 implements INodeType {
}),
];
} catch (error) {
if (this.continueOnFail()) {
if (this.continueOnFail(error)) {
returnData.push({ json: { error: error.message } });
} else {
throw error;
Expand Down Expand Up @@ -792,7 +792,7 @@ export class AirtableV1 implements INodeType {

returnData.push(...executionData);
} catch (error) {
if (this.continueOnFail()) {
if (this.continueOnFail(error)) {
returnData.push({ json: { error: error.message } });
continue;
}
Expand Down Expand Up @@ -880,7 +880,7 @@ export class AirtableV1 implements INodeType {
rows.length = 0;
}
} catch (error) {
if (this.continueOnFail()) {
if (this.continueOnFail(error)) {
returnData.push({ json: { error: error.message } });
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export async function execute(
returnData.push(...executionData);
} catch (error) {
error = processAirtableError(error as NodeApiError, undefined, i);
if (this.continueOnFail()) {
if (this.continueOnFail(error)) {
returnData.push({ json: { error: error.message } });
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export async function execute(
returnData.push(...executionData);
} catch (error) {
error = processAirtableError(error as NodeApiError, undefined, i);
if (this.continueOnFail()) {
if (this.continueOnFail(error)) {
returnData.push({ json: { message: error.message, error } });
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export async function execute(
returnData.push(...executionData);
} catch (error) {
error = processAirtableError(error as NodeApiError, id, i);
if (this.continueOnFail()) {
if (this.continueOnFail(error)) {
returnData.push({ json: { error: error.message } });
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export async function execute(
returnData.push(...executionData);
} catch (error) {
error = processAirtableError(error as NodeApiError, id, i);
if (this.continueOnFail()) {
if (this.continueOnFail(error)) {
returnData.push({ json: { error: error.message } });
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ export async function execute(

returnData.push(...executionData);
} catch (error) {
if (this.continueOnFail()) {
if (this.continueOnFail(error)) {
returnData.push({ json: { message: error.message, error }, pairedItem: { item: i } });
continue;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export async function execute(
returnData.push(...executionData);
} catch (error) {
error = processAirtableError(error as NodeApiError, recordId, i);
if (this.continueOnFail()) {
if (this.continueOnFail(error)) {
returnData.push({ json: { message: error.message, error } });
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export async function execute(
returnData.push(...executionData);
} catch (error) {
error = processAirtableError(error as NodeApiError, undefined, i);
if (this.continueOnFail()) {
if (this.continueOnFail(error)) {
returnData.push({ json: { message: error.message, error } });
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/Amqp/Amqp.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ export class Amqp implements INodeType {

return [this.helpers.returnJsonArray(responseData)];
} catch (error) {
if (this.continueOnFail()) {
if (this.continueOnFail(error)) {
return [this.helpers.returnJsonArray({ error: error.message })];
} else {
throw error;
Expand Down
6 changes: 3 additions & 3 deletions packages/nodes-base/nodes/ApiTemplateIo/ApiTemplateIo.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ export class ApiTemplateIo implements INodeType {

returnData.push(responseData as IDataObject);
} catch (error) {
if (this.continueOnFail()) {
if (this.continueOnFail(error)) {
returnData.push({ json: { error: error.message } });
continue;
}
Expand Down Expand Up @@ -471,7 +471,7 @@ export class ApiTemplateIo implements INodeType {
}
returnData.push(responseData as IDataObject);
} catch (error) {
if (this.continueOnFail()) {
if (this.continueOnFail(error)) {
returnData.push({ json: { error: error.message } });
continue;
}
Expand Down Expand Up @@ -561,7 +561,7 @@ export class ApiTemplateIo implements INodeType {
}
returnData.push(responseData as IDataObject);
} catch (error) {
if (this.continueOnFail()) {
if (this.continueOnFail(error)) {
returnData.push({ json: { error: error.message } });
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/Asana/Asana.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2425,7 +2425,7 @@ export class Asana implements INodeType {
),
);
} catch (error) {
if (this.continueOnFail()) {
if (this.continueOnFail(error)) {
returnData.push({ error: error.message });
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/Autopilot/Autopilot.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ export class Autopilot implements INodeType {
);
returnData.push(...executionData);
} catch (error) {
if (this.continueOnFail()) {
if (this.continueOnFail(error)) {
const exectionErrorWithMetaData = this.helpers.constructExecutionMetaData(
[{ json: { error: error.message } }],
{ itemData: { item: i } },
Expand Down
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/Aws/AwsLambda.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ export class AwsLambda implements INodeType {
} as IDataObject);
}
} catch (error) {
if (this.continueOnFail()) {
if (this.continueOnFail(error)) {
returnData.push({ error: (error as JsonObject).message });
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/Aws/AwsSns.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ export class AwsSns implements INodeType {
} as IDataObject);
}
} catch (error) {
if (this.continueOnFail()) {
if (this.continueOnFail(error)) {
returnData.push({ error: error.message });
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ export class AwsCertificateManager implements INodeType {
returnData.push(...executionData);
}
} catch (error) {
if (this.continueOnFail()) {
if (this.continueOnFail(error)) {
returnData.push({ json: { error: error.message } });
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ export class AwsComprehend implements INodeType {
returnData.push(responseData as IDataObject);
}
} catch (error) {
if (this.continueOnFail()) {
if (this.continueOnFail(error)) {
returnData.push({ error: error.message });
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/Aws/DynamoDB/AwsDynamoDB.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ export class AwsDynamoDB implements INodeType {
returnData.push(...executionData);
}
} catch (error) {
if (this.continueOnFail()) {
if (this.continueOnFail(error)) {
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray({ error: error.message }),
{ itemData: { item: i } },
Expand Down
Loading
Loading