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

refactor(core): Reorganize error hierarchy in core and workflow packages (no-changelog) #7820

Merged
merged 7 commits into from
Nov 27, 2023

Conversation

ivov
Copy link
Contributor

@ivov ivov commented Nov 27, 2023

Ensure all errors in core and workflow inherit from ApplicationError so that we start normalizing all the errors we report to Sentry

Follow-up to: #7757 (comment)

core package

ApplicationError

  • FileSystemError (abstract)
    • FileNotFoundError
    • DisallowedFilepathError
  • BinaryDataError (abstract)
    • InvalidModeError
    • InvalidManagerError
  • InvalidExecutionMetadataError

workflow package

ApplicationError

  • ExecutionBaseError (abstract)
    • WorkflowActivationError
      • WorkflowDeactivationError
      • WebhookTakenError
    • WorkflowOperationError
      • SubworkflowOperationError
        • CliWorkflowOperationError
    • ExpressionError
      • ExpressionExtensionError
    • NodeError (abstract)
      • NodeOperationError
      • NodeApiError
    • NodeSSLError

Up next:

  • Reorganize errors in cli
  • Flatten the hierarchy in workflow (do we really need ExecutionBaseError?)
  • Remove ExecutionError type
  • Stop throwing plain Errors
  • Replace severity with level
  • Add node and credential types as tags
  • Add workflow IDs and execution IDs as extras

@n8n-assistant n8n-assistant bot added core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team labels Nov 27, 2023
Copy link
Member

@netroy netroy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

besides the comments, LGTM

export abstract class ExecutionBaseError extends ApplicationError {
description: string | null | undefined;

cause: Error | JsonObject | undefined;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should update this to be 2 separate properties, and stop conflating the 2 distinct pieces of information.
cause should not be used to store JSONObject. We don't have to make this change in this PR, but we should make this change soon, to make errors more type-safe, and also to be able to clearly distinguish between a cause, and remote json responses in the UI.

Comment on lines 42 to +45
if (originalException instanceof ExecutionBaseError && originalException.severity === 'warning')
return null;

if (originalException instanceof ReportableError) {
if (originalException instanceof ApplicationError) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since ExecutionBaseError now extends ApplicationError, these checks could be unified, and we can most likely remove the ExecutionBaseError import all together here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean unifying like if (level === 'warning' || severity === 'warning') return null;?

If so, severity is present in ExecutionBaseError but absent in ApplicationError, so we'd still need to check for originalException instanceof ExecutionBaseError, meaning the check is moved but not unified. Might be best to clean this up once we do away with severity altogether?

if (originalException instanceof ApplicationError) {
	if (
		originalException instanceof ExecutionBaseError &&
		originalException.severity === 'warning'
	) {
		return null;
	}

	const { level, extra } = originalException;

	if (level === 'warning') return null;
	event.level = level;
	if (extra) event.extra = { ...event.extra, ...extra };
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can do this in another PR.

packages/cli/src/ActiveWebhooks.ts Outdated Show resolved Hide resolved
Copy link

cypress bot commented Nov 27, 2023

1 flaky test on run #3041 ↗︎

0 283 5 0 Flakiness 1

Details:

🌳 🖥️ browsers:node18.12.0-chrome107 🤖 ivov 🗃️ e2e/*
Project: n8n Commit: ff574e1e2c
Status: Passed Duration: 06:05 💡
Started: Nov 27, 2023 1:34 PM Ended: Nov 27, 2023 1:40 PM
Flakiness  cypress/e2e/12-canvas.cy.ts • 1 flaky test

View Output Video

Test Artifacts
Canvas Node Manipulation and Navigation > should add merge node and test connections Screenshots Video

Review all test suite changes for PR #7820 ↗︎

Copy link
Contributor

✅ All Cypress E2E specs passed

@ivov ivov merged commit dff8456 into master Nov 27, 2023
21 checks passed
@ivov ivov deleted the reorganize-error-hierarchy-in-core-and-workflow-packages branch November 27, 2023 14:33
ivov added a commit that referenced this pull request Nov 28, 2023
…elog) (#7839)

Ensure all errors in `cli` inherit from `ApplicationError` to continue
normalizing all the errors we report to Sentry

Follow-up to: #7820
rishikeshjoshi pushed a commit to rishikeshjoshi/n8n that referenced this pull request Nov 28, 2023
…elog) (n8n-io#7839)

Ensure all errors in `cli` inherit from `ApplicationError` to continue
normalizing all the errors we report to Sentry

Follow-up to: n8n-io#7820
ivov added a commit that referenced this pull request Nov 30, 2023
…auses (no-changelog) (#7880)

Store the third-party API response error separately from the error
stored as `cause`

Follow-up to:
#7820 (comment)
@janober
Copy link
Member

janober commented Dec 1, 2023

Got released with n8n@1.19.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team Released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants