Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix(core): Handle credential decryption failures gracefully on the API #13166

Merged
merged 1 commit into from
Feb 10, 2025

Conversation

netroy
Copy link
Member

@netroy netroy commented Feb 10, 2025

Summary

If the credentials table contains any values that are either invalid JSON when decrypted, or values that fail to decrypt, the API endpoints for fetching credentials on the frontend should not crash, and instead return a {} as decrypted data, which in turn marks these credentials with the Needs first setup tag on the frontend, so that users can then edit and fix these credentials.

Related Linear tickets, Github issues, and Community forum posts

Fixes #12949
Fixes #12940
CAT-632
CAT-616

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)

@n8n-assistant n8n-assistant bot added core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team labels Feb 10, 2025
Copy link

codecov bot commented Feb 10, 2025

Codecov Report

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

Files with missing lines Patch % Lines
...ackages/cli/src/credentials/credentials.service.ts 81.81% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@tomi tomi self-requested a review February 10, 2025 12:15
Copy link
Collaborator

@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.

Code looks good. Testing this next

this.errorReporter.error(error, {
level: 'error',
extra: { credentialId: credential.id },
tags: { credentialType: credential.type },
Copy link
Collaborator

@tomi tomi Feb 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want this to be a tag or extra?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kept the type in the tags to be able to have an overview, to see if there is any pattern there.

Copy link
Collaborator

@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.

Works nicely 👏 🚀

Copy link
Contributor

✅ All Cypress E2E specs passed

Copy link

cypress bot commented Feb 10, 2025

n8n    Run #9208

Run Properties:  status check passed Passed #9208  •  git commit 6c899df85b: 🌳 🖥️ browsers:node18.12.0-chrome107 🤖 netroy 🗃️ e2e/*
Project n8n
Branch Review handle-credential-decryption-failures-gracefully
Run status status check passed Passed #9208
Run duration 04m 52s
Commit git commit 6c899df85b: 🌳 🖥️ browsers:node18.12.0-chrome107 🤖 netroy 🗃️ e2e/*
Committer कारतोफ्फेलस्क्रिप्ट™
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 5
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 435
View all changes introduced in this branch ↗︎

@netroy netroy merged commit a4c5334 into master Feb 10, 2025
52 checks passed
@netroy netroy deleted the handle-credential-decryption-failures-gracefully branch February 10, 2025 12:40
@github-actions github-actions bot mentioned this pull request Feb 13, 2025
@janober
Copy link
Member

janober commented Feb 13, 2025

Got released with n8n@1.79.0

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team Released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Credentials could not be decrypted. There was a problem using init data: credentials could not be decrypted
3 participants