mirror of
https://github.com/n8n-io/n8n.git
synced 2025-02-21 02:56:40 -08:00
refactor(core): Stop reporting EAUTH
error codes to Sentry (no-changelog) (#9496)
This commit is contained in:
parent
8737c0965e
commit
f8683c31e0
|
@ -537,7 +537,9 @@ export class ActiveWorkflowManager {
|
|||
const dbWorkflow = existingWorkflow ?? (await this.workflowRepository.findById(workflowId));
|
||||
|
||||
if (!dbWorkflow) {
|
||||
throw new WorkflowActivationError(`Failed to find workflow with ID "${workflowId}"`);
|
||||
throw new WorkflowActivationError(`Failed to find workflow with ID "${workflowId}"`, {
|
||||
level: 'warning',
|
||||
});
|
||||
}
|
||||
|
||||
if (shouldDisplayActivationMessage) {
|
||||
|
@ -564,6 +566,7 @@ export class ActiveWorkflowManager {
|
|||
if (!canBeActivated) {
|
||||
throw new WorkflowActivationError(
|
||||
`Workflow ${dbWorkflow.display()} has no node to start the workflow - at least one trigger, poller or webhook node is required`,
|
||||
{ level: 'warning' },
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -92,13 +92,7 @@ export class ActiveWorkflows {
|
|||
|
||||
throw new WorkflowActivationError(
|
||||
`There was a problem activating the workflow: "${error.message}"`,
|
||||
{
|
||||
cause: error,
|
||||
node: triggerNode,
|
||||
level: ['ETIMEDOUT', 'ECONNREFUSED'].some((code) => error.message.includes(code))
|
||||
? 'warning'
|
||||
: 'error',
|
||||
},
|
||||
{ cause: error, node: triggerNode },
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,20 @@ export class WorkflowActivationError extends ExecutionBaseError {
|
|||
this.node = node;
|
||||
this.workflowId = workflowId;
|
||||
this.message = message;
|
||||
if (level) this.level = level;
|
||||
this.setLevel(level);
|
||||
}
|
||||
|
||||
private setLevel(level?: ApplicationError['level']) {
|
||||
if (level) {
|
||||
this.level = level;
|
||||
return;
|
||||
}
|
||||
|
||||
if (['ETIMEDOUT', 'ECONNREFUSED', 'EAUTH'].some((code) => this.message.includes(code))) {
|
||||
this.level = 'warning';
|
||||
return;
|
||||
}
|
||||
|
||||
this.level = 'error';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
import { WorkflowActivationError } from '@/index';
|
||||
|
||||
describe('WorkflowActivationError', () => {
|
||||
it('should default to `error` level', () => {
|
||||
const error = new WorkflowActivationError('message');
|
||||
expect(error.level).toBe('error');
|
||||
});
|
||||
|
||||
const cause = new Error('Some error message');
|
||||
|
||||
it('should set `level` based on arg', () => {
|
||||
const firstError = new WorkflowActivationError('message', { level: 'warning', cause });
|
||||
|
||||
expect(firstError.level).toBe('warning');
|
||||
|
||||
const secondError = new WorkflowActivationError('message', { level: 'error', cause });
|
||||
|
||||
expect(secondError.level).toBe('error');
|
||||
});
|
||||
|
||||
test.each(['ETIMEDOUT', 'ECONNREFUSED', 'EAUTH'])(
|
||||
'should set `level` to `warning` for %s',
|
||||
(code) => {
|
||||
const error = new WorkflowActivationError(code, { cause });
|
||||
|
||||
expect(error.level).toBe('warning');
|
||||
},
|
||||
);
|
||||
});
|
Loading…
Reference in a new issue