mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
refactor(core): Stop reporting to Sentry credential-not-found error (no-changelog) (#7665)
https://n8nio.sentry.io/issues/4528134408
This commit is contained in:
parent
0468ded0db
commit
16a1a92f18
|
@ -32,6 +32,7 @@ import type {
|
||||||
INodeTypes,
|
INodeTypes,
|
||||||
IWorkflowExecuteAdditionalData,
|
IWorkflowExecuteAdditionalData,
|
||||||
ICredentialTestFunctions,
|
ICredentialTestFunctions,
|
||||||
|
Severity,
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
import {
|
import {
|
||||||
ICredentialsHelper,
|
ICredentialsHelper,
|
||||||
|
@ -85,6 +86,15 @@ const mockNodeTypes: INodeTypes = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class CredentialNotFoundError extends Error {
|
||||||
|
severity: Severity;
|
||||||
|
|
||||||
|
constructor(credentialId: string, credentialType: string) {
|
||||||
|
super(`Credential with ID "${credentialId}" does not exist for type "${credentialType}".`);
|
||||||
|
this.severity = 'warning';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Service()
|
@Service()
|
||||||
export class CredentialsHelper extends ICredentialsHelper {
|
export class CredentialsHelper extends ICredentialsHelper {
|
||||||
constructor(
|
constructor(
|
||||||
|
@ -257,17 +267,17 @@ export class CredentialsHelper extends ICredentialsHelper {
|
||||||
throw new Error(`Credential "${nodeCredential.name}" of type "${type}" has no ID.`);
|
throw new Error(`Credential "${nodeCredential.name}" of type "${type}" has no ID.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const credential = userId
|
let credential: CredentialsEntity;
|
||||||
|
|
||||||
|
try {
|
||||||
|
credential = userId
|
||||||
? await Db.collections.SharedCredentials.findOneOrFail({
|
? await Db.collections.SharedCredentials.findOneOrFail({
|
||||||
relations: ['credentials'],
|
relations: ['credentials'],
|
||||||
where: { credentials: { id: nodeCredential.id, type }, userId },
|
where: { credentials: { id: nodeCredential.id, type }, userId },
|
||||||
}).then((shared) => shared.credentials)
|
}).then((shared) => shared.credentials)
|
||||||
: await Db.collections.Credentials.findOneByOrFail({ id: nodeCredential.id, type });
|
: await Db.collections.Credentials.findOneByOrFail({ id: nodeCredential.id, type });
|
||||||
|
} catch (error) {
|
||||||
if (!credential) {
|
throw new CredentialNotFoundError(nodeCredential.id, type);
|
||||||
throw new Error(
|
|
||||||
`Credential with ID "${nodeCredential.id}" does not exist for type "${type}".`,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Credentials(
|
return new Credentials(
|
||||||
|
|
Loading…
Reference in a new issue