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,
|
||||
IWorkflowExecuteAdditionalData,
|
||||
ICredentialTestFunctions,
|
||||
Severity,
|
||||
} from 'n8n-workflow';
|
||||
import {
|
||||
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()
|
||||
export class CredentialsHelper extends ICredentialsHelper {
|
||||
constructor(
|
||||
|
@ -257,17 +267,17 @@ export class CredentialsHelper extends ICredentialsHelper {
|
|||
throw new Error(`Credential "${nodeCredential.name}" of type "${type}" has no ID.`);
|
||||
}
|
||||
|
||||
const credential = userId
|
||||
? await Db.collections.SharedCredentials.findOneOrFail({
|
||||
relations: ['credentials'],
|
||||
where: { credentials: { id: nodeCredential.id, type }, userId },
|
||||
}).then((shared) => shared.credentials)
|
||||
: await Db.collections.Credentials.findOneByOrFail({ id: nodeCredential.id, type });
|
||||
let credential: CredentialsEntity;
|
||||
|
||||
if (!credential) {
|
||||
throw new Error(
|
||||
`Credential with ID "${nodeCredential.id}" does not exist for type "${type}".`,
|
||||
);
|
||||
try {
|
||||
credential = userId
|
||||
? await Db.collections.SharedCredentials.findOneOrFail({
|
||||
relations: ['credentials'],
|
||||
where: { credentials: { id: nodeCredential.id, type }, userId },
|
||||
}).then((shared) => shared.credentials)
|
||||
: await Db.collections.Credentials.findOneByOrFail({ id: nodeCredential.id, type });
|
||||
} catch (error) {
|
||||
throw new CredentialNotFoundError(nodeCredential.id, type);
|
||||
}
|
||||
|
||||
return new Credentials(
|
||||
|
|
Loading…
Reference in a new issue