-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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): Migrate all errors in cli package to new hierarchy #13478
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few comments about which error class to use. Didn't go through all of them as there are so many. In the future maybe we can do these in smaller batches so they are easier to review.
@@ -238,7 +238,7 @@ export class ActiveWorkflowManager { | |||
}); | |||
|
|||
if (workflowData === null) { | |||
throw new ApplicationError('Could not find workflow', { extra: { workflowId } }); | |||
throw new UnexpectedError('Could not find workflow', { extra: { workflowId } }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could change the .findOne
above to .findOneOrFail
and remove this if, as non BaseError
s are treated as unexpected
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer not to change any logic in this PR if possible.
|
||
export class AbortedExecutionRetryError extends ApplicationError { | ||
export class AbortedExecutionRetryError extends UnexpectedError { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this error transient by nature? If so it should extend OperationalError
instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This error is part of a workaround for the root issue that we should not be sending requests to retry an execution that was cancelled before starting.
|
||
export class ExternalSecretsProviderNotFoundError extends ApplicationError { | ||
export class ExternalSecretsProviderNotFoundError extends UnexpectedError { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The provider name seems to be coming in a request to the controller. Hence that makes this a UserError
as it can fail due to input from user
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The frontend should never allow sending an external secrets provider name that does not exist.
@@ -146,7 +146,7 @@ export class ExecutionService { | |||
if (!execution.data.executionData) throw new AbortedExecutionRetryError(); | |||
|
|||
if (execution.finished) { | |||
throw new ApplicationError('The execution succeeded, so it cannot be retried.'); | |||
throw new UnexpectedError('The execution succeeded, so it cannot be retried.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is transient? So OperationalError?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This error is part of a workaround for the root issue that we should not be sending requests to retry an execution with success
status.
@@ -188,7 +188,7 @@ export class ExecutionService { | |||
})) as IWorkflowBase; | |||
|
|||
if (workflowData === undefined) { | |||
throw new ApplicationError( | |||
throw new UnexpectedError( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this happen if the execution or workflow gets deleted? Should it be OperationalError or UserError instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this and the above cases, we've been assuming that trying to operate on a resource that no longer exists is a UserError
. I don't fully agree and would rather err on the side of caution, but I'll go with UserError
to be consistent.
@@ -44,7 +44,7 @@ export const parseRangeQuery = ( | |||
|
|||
if (jsonFilter.waitTill) jsonFilter.waitTill = Boolean(jsonFilter.waitTill); | |||
|
|||
if (!isValid(jsonFilter)) throw new ApplicationError('Query does not match schema'); | |||
if (!isValid(jsonFilter)) throw new UnexpectedError('Query does not match schema'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This input is coming from users --> UserError
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is coming from our own frontend. Cases like I'd think this is unexpected and we'd want to report it?
|
||
export class TaskDeferredError extends ApplicationError { | ||
export class TaskDeferredError extends UserError { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is transient --> OperationalError
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a special case in that we're relying on this to give time to the launcher to start a runner. So not really an error at all, so not sure any of the existing categories fit?
Follow-up to: #12267
Exempting
webhook-helpers.ts
which is currently being refactored.