-
Notifications
You must be signed in to change notification settings - Fork 50.8k
fix(core): Prevent credentials saving if missing required properties #22213
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
base: master
Are you sure you want to change the base?
fix(core): Prevent credentials saving if missing required properties #22213
Conversation
BundleMonUnchanged files (2)
No change in files bundle size Groups updated (2)
Final result: ✅ View report in BundleMon website ➡️ |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
Found 6 test failures on Blacksmith runners: Failures
|
4ffdf45 to
37ab3eb
Compare
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.
1 issue found across 12 files
Prompt for AI agents (all 1 issues)
Understand the root cause of the following 1 issues and fix them.
<file name="packages/cli/src/credentials/credentials.service.ts">
<violation number="1" location="packages/cli/src/credentials/credentials.service.ts:893">
Rule violated: **Prefer Typeguards over Type casting**
`opts.data` is narrowed to `ICredentialDataDecryptedObject` with an `as` assertion, violating the “Prefer Typeguards over Type casting” rule. Propagate the proper credential-data type through `CreateCredentialOptions`/DTO typings (or introduce a type guard) so this invocation doesn’t rely on `as`.</violation>
</file>
Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR
| } | ||
|
|
||
| private async createCredential(opts: CreateCredentialOptions, user: User) { | ||
| this.checkCredentialData(opts.type, opts.data as ICredentialDataDecryptedObject); |
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.
Rule violated: Prefer Typeguards over Type casting
opts.data is narrowed to ICredentialDataDecryptedObject with an as assertion, violating the “Prefer Typeguards over Type casting” rule. Propagate the proper credential-data type through CreateCredentialOptions/DTO typings (or introduce a type guard) so this invocation doesn’t rely on as.
Prompt for AI agents
Address the following comment on packages/cli/src/credentials/credentials.service.ts at line 893:
<comment>`opts.data` is narrowed to `ICredentialDataDecryptedObject` with an `as` assertion, violating the “Prefer Typeguards over Type casting” rule. Propagate the proper credential-data type through `CreateCredentialOptions`/DTO typings (or introduce a type guard) so this invocation doesn’t rely on `as`.</comment>
<file context>
@@ -872,6 +890,7 @@ export class CredentialsService {
}
private async createCredential(opts: CreateCredentialOptions, user: User) {
+ this.checkCredentialData(opts.type, opts.data as ICredentialDataDecryptedObject);
const encryptedCredential = this.createEncryptedData({
id: null,
</file context>
|
E2E Tests: n8n tests failed after 14m 50.5s Run Details
Failed Spec Files
Groups
This message was posted automatically by
currents.dev | Integration Settings
|
Summary
This PR adds logic to prevent saving credentials which lacks mandatory parameters
Related Linear tickets, Github issues, and Community forum posts
https://linear.app/n8n/issue/PAY-4098/credentials-saved-successfully-without-mandatory-fields
Review / Merge checklist
release/backport(if the PR is an urgent fix that needs to be backported)