fix(editor): Load credentials for workflow before determining credentials errors #9876
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
We are attempting to get node credentials errors before we load the credentials in the store. This causes the UI to show "issues with the credentials" even though there are none. Loading the credentials as soon as we initiate the view seems to fix the issue.
Specifically, we are trying to get the credentials errors for
predefinedCredentialType
and here, we attempt to get the type by callinggetCredentialsByType
, but that method depends onallCredentialsByType
which at the same time depends on the state propertyallCredentials
. At the time of calling the credentials have not been loaded in the store, so it returns[]
even though it should have returned the credentials type. This empty array causes the logic to show an incorrect error.The execution does follow:
Mounted
->ready (jsplumb)
->initView
- >openWorkflow
->addNodes
->refreshNodeIssues
->getNodeIssue
->getNodeCredentialIssues
->credentialsStore.getCredentialsByType
(were we return [] because the store has not loaded yet.) -> at some point later we load the credentials for that workflow in the store (this should have happened before getNodeCredentialIssues)@cstuncsik Can you please have a look? I'm not too familiar with this side of the code, so I'm not sure whether this would break something else or if it's the best approach to solve the issue. So far, it seems to fix the problem.
Related Linear tickets, Github issues, and Community forum posts
https://linear.app/n8n/issue/ADO-2280/http-request-shows-credentials-not-set-warning-in-ui-despite
Before changes
https://www.loom.com/share/5c07e76288e84041b6b8abdf99a33b30?from_recorder=1&focus_title=1
After the changes
https://www.loom.com/share/7ac13702dced4784bc1bb820a29ed5bc?from_recorder=1&focus_title=1
Review / Merge checklist
release/backport
(if the PR is an urgent fix that needs to be backported)