refactor: Switch plain errors in nodes-base to ApplicationError (no-changelog) (#7914)

Ensure all errors in `nodes-base` are `ApplicationError` or children of
it and contain no variables in the message, to continue normalizing all
the backend errors we report to Sentry. Also, skip reporting to Sentry
errors from user input and from external APIs. In future we should
refine `ApplicationError` to more specific errors.

Follow-up to: [#7877](https://github.com/n8n-io/n8n/pull/7877)

- [x] Test workflows:
https://github.com/n8n-io/n8n/actions/runs/7084627970
- [x] e2e: https://github.com/n8n-io/n8n/actions/runs/7084936861

---------

Co-authored-by: Michael Kret <michael.k@radency.com>
This commit is contained in:
Iván Ovejero
2023-12-05 11:17:08 +01:00
committed by GitHub
parent 38b88b946b
commit e77fd5d286
33 changed files with 164 additions and 86 deletions

View File

@@ -6,7 +6,7 @@ import type {
ILoadOptionsFunctions,
IDataObject,
} from 'n8n-workflow';
import { jsonParse } from 'n8n-workflow';
import { ApplicationError, jsonParse } from 'n8n-workflow';
import moment from 'moment';
import { Eq } from './QueryFunctions';
@@ -79,7 +79,7 @@ export function prepareOptional(optionals: IDataObject): IDataObject {
try {
response[key] = jsonParse(optionals[key] as string);
} catch (error) {
throw new Error('Invalid JSON for artifacts');
throw new ApplicationError('Invalid JSON for artifacts', { level: 'warning' });
}
} else if (key === 'tags') {
response[key] = splitTags(optionals[key] as string);
@@ -107,7 +107,7 @@ export async function prepareCustomFields(
try {
customFieldsJson = jsonParse(customFieldsJson);
} catch (error) {
throw new Error('Invalid JSON for customFields');
throw new ApplicationError('Invalid JSON for customFields', { level: 'warning' });
}
}