-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
feat(core): Add includeData parameter to GET /credentials
#12220
feat(core): Add includeData parameter to GET /credentials
#12220
Conversation
This returns the decrypted data property of credentials if the user has the `credential:update` scope for it.
GET /credentials
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.
Good stuff 👏 Some comments
packages/@n8n/api-types/src/dto/credentials/credentials-get-many-request.dto.ts
Outdated
Show resolved
Hide resolved
packages/@n8n/api-types/src/dto/credentials/credentials-get-many-request.dto.ts
Outdated
Show resolved
Hide resolved
packages/@n8n/api-types/src/dto/credentials/credentials-get-one-request.dto.ts
Outdated
Show resolved
Hide resolved
packages/@n8n/api-types/src/dto/credentials/credentials-get-many-request.dto.ts
Outdated
Show resolved
Hide resolved
credentials = credentials.map((c) => | ||
this.roleService.addScopes(c, user, projectRelations!), | ||
); | ||
} | ||
|
||
if (includeData) { | ||
credentials = credentials.map((c: CredentialsEntity & ScopesField) => { | ||
if (c.scopes.includes('credential:update')) { |
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 don't have all thecontext but why do we include the data only if there is a credential:update
scope? Do we test this case?
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.
It's a convention. The FE only shows the data if the user has the permission to update it. The GET /credentials/:id
works the same way.
packages/cli/src/databases/repositories/credentials.repository.ts
Outdated
Show resolved
Hide resolved
9f3a0d6
to
f1c14f6
Compare
packages/@n8n/api-types/src/dto/credentials/credentials-get-many-request.dto.ts
Outdated
Show resolved
Hide resolved
packages/@n8n/api-types/src/dto/credentials/credentials-get-many-request.dto.ts
Outdated
Show resolved
Hide resolved
packages/@n8n/api-types/src/dto/credentials/credentials-get-many-request.dto.ts
Show resolved
Hide resolved
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.
Looks good on a first scan. testing it now.
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 changes quite a lot of code in CredentialsService
, that we should definitely add unit tests for. There are a lot of old and new code branches that have very little protection against regressions.
We should either add those tests in this PR, or create a tech-debt ticket to add unit tests for these.
}: { | ||
listQueryOptions?: ListQuery.Options & { includeData?: boolean }; | ||
includeScopes?: boolean; | ||
includeData?: boolean; | ||
} = {}, |
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.
not in this PR, but this could be it's own DTO in the future.
n8n Run #8522
Run Properties:
|
Project |
n8n
|
Branch Review |
pay-2376-add-data-property-to-credentials-list-response-try-3
|
Run status |
Passed #8522
|
Run duration | 04m 42s |
Commit |
79563021ae: 🌳 🖥️ browsers:node18.12.0-chrome107 🤖 despairblue 🗃️ e2e/*
|
Committer | Danny Martini |
View all properties for this run ↗︎ |
Test results | |
---|---|
Failures |
0
|
Flaky |
1
|
Pending |
0
|
Skipped |
0
|
Passing |
484
|
View all changes introduced in this branch ↗︎ |
✅ All Cypress E2E specs passed |
select is always defined, see condition above
3458b67
to
8a1b523
Compare
✅ All Cypress E2E specs passed |
Summary
This allows the FE to find out if a credential has been filled in already or not (empty data property). We want to make use of this to show users all empty credentials after a source control pull operation.
Commits:
GET /credentials
andGET /credentials/:credentialId
includeData
parameter toGET /credentials
Related Linear tickets, Github issues, and Community forum posts
https://linear.app/n8n/issue/PAY-2376/add-data-property-to-credentials-list-response
Review / Merge checklist
Docs updated or follow-up ticket created.PR Labeled withrelease/backport
(if the PR is an urgent fix that needs to be backported)