Skip to content
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

Merged

Conversation

despairblue
Copy link
Contributor

@despairblue despairblue commented Dec 13, 2024

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:

  • add DTOs for GET /credentials and GET /credentials/:credentialId
  • feat(core): Add includeData parameter to GET /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

  • PR title and summary are descriptive. (conventions)
  • Docs updated or follow-up ticket created.
  • Tests included.
  • PR Labeled with release/backport (if the PR is an urgent fix that needs to be backported)

@despairblue despairblue changed the title pay 2376 add data property to credentials list response try 3 feat(core): Add includeData parameter to GET /credentials Dec 13, 2024
@n8n-assistant n8n-assistant bot added core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team labels Dec 13, 2024
Copy link

codecov bot commented Dec 18, 2024

Codecov Report

Attention: Patch coverage is 95.91837% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
packages/@n8n/api-types/src/dto/index.ts 0.00% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@r00gm r00gm marked this pull request as ready for review December 18, 2024 08:56
Copy link
Contributor

@tomi tomi left a 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/cli/src/credentials/credentials.service.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')) {
Copy link
Contributor

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?

Copy link
Contributor Author

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/credentials/credentials.service.ts Outdated Show resolved Hide resolved
@despairblue despairblue requested review from tomi and netroy December 27, 2024 09:27
@despairblue despairblue force-pushed the pay-2376-add-data-property-to-credentials-list-response-try-3 branch from 9f3a0d6 to f1c14f6 Compare December 27, 2024 09:45
@despairblue despairblue marked this pull request as ready for review December 30, 2024 10:55
@despairblue despairblue requested a review from netroy December 30, 2024 10:55
Copy link
Member

@netroy netroy left a 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.

@despairblue despairblue requested a review from netroy December 30, 2024 12:13
netroy
netroy previously approved these changes Dec 30, 2024
Copy link
Member

@netroy netroy left a 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.

Comment on lines +70 to 74
}: {
listQueryOptions?: ListQuery.Options & { includeData?: boolean };
includeScopes?: boolean;
includeData?: boolean;
} = {},
Copy link
Member

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.

Copy link

cypress bot commented Dec 30, 2024

n8n    Run #8522

Run Properties:  status check passed Passed #8522  •  git commit 79563021ae: 🌳 🖥️ browsers:node18.12.0-chrome107 🤖 despairblue 🗃️ e2e/*
Project n8n
Branch Review pay-2376-add-data-property-to-credentials-list-response-try-3
Run status status check passed Passed #8522
Run duration 04m 42s
Commit git commit 79563021ae: 🌳 🖥️ browsers:node18.12.0-chrome107 🤖 despairblue 🗃️ e2e/*
Committer Danny Martini
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 1
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 484
View all changes introduced in this branch ↗︎

Copy link
Contributor

✅ All Cypress E2E specs passed

select is always defined, see condition above
@despairblue despairblue force-pushed the pay-2376-add-data-property-to-credentials-list-response-try-3 branch from 3458b67 to 8a1b523 Compare December 30, 2024 16:27
@despairblue despairblue requested a review from netroy December 30, 2024 17:16
@despairblue despairblue requested a review from netroy December 31, 2024 10:23
Copy link
Contributor

✅ All Cypress E2E specs passed

@despairblue despairblue merged commit f56ad8c into master Dec 31, 2024
42 checks passed
@despairblue despairblue deleted the pay-2376-add-data-property-to-credentials-list-response-try-3 branch December 31, 2024 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants