fix(editor): Persist switching workflow credential resolver back to system resolver (#31703)

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Guillaume Jacquart 2026-06-04 15:56:47 +02:00 committed by GitHub
parent a7f660c8d4
commit f723f54879
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 42 additions and 0 deletions

View File

@ -998,6 +998,40 @@ describe('WorkflowSettingsVue', () => {
);
});
it('should save with empty credentialResolverId when switching back to the system resolver', async () => {
workflowDocumentStore.setSettings({ credentialResolverId: 'resolver-1' });
const { getByTestId, getByRole } = createComponent({ pinia });
await flushPromises();
await waitFor(() => {
expect(restApiClient.getCredentialResolvers).toHaveBeenCalled();
});
// Open the dropdown and pick the n8n system resolver
const resolverContainer = getByTestId('workflow-settings-credential-resolver');
await userEvent.click(within(resolverContainer).getByRole('combobox'));
await waitFor(async () => {
const options = within(document.body as HTMLElement).getAllByRole('option');
const systemResolver = options.find((o) => o.textContent?.includes('N8n Resolver'));
expect(systemResolver).toBeTruthy();
await userEvent.click(systemResolver!);
});
await flushPromises();
await userEvent.click(getByRole('button', { name: 'Save' }));
// `undefined` would be stripped during serialization and the merge on the backend
// would keep the old id, so the clear must be sent as an explicit empty string.
expect(workflowsStore.updateWorkflow).toHaveBeenCalledWith(
'1',
expect.objectContaining({
settings: expect.objectContaining({ credentialResolverId: '' }),
}),
);
});
it('should disable credential resolver dropdown when environment is read-only', async () => {
sourceControlStore.preferences.branchReadOnly = true;

View File

@ -712,6 +712,14 @@ const saveSettings = async () => {
}
delete data.settings.maxExecutionTimeout;
// `credentialResolverId` is `undefined` in-memory when the n8n system resolver is
// selected. The backend merges settings for partial updates, so an absent key keeps
// the previously-saved id. Send an explicit empty string so the merge clears it
// (the backend drops the falsy value before persisting).
if (isCredentialResolverEnabled.value && !data.settings.credentialResolverId) {
data.settings.credentialResolverId = '';
}
isLoading.value = true;
data.versionId = workflowDocumentStore.value.versionId;
data.expectedChecksum = workflowDocumentStore.value.checksum;