Commit f6ab3d5
* fix: surface HTTP status in audit errors + workaround oAuth2 schema bug (#736, #740)
## #736 — n8n_audit_instance error message includes HTTP status
Pre-fix the warning was `Built-in audit failed: <message>` regardless of cause.
The reporter's Zeabur deployment produced `Invalid URL` from inside n8n's own
audit code (likely missing N8N_PROTOCOL/N8N_HOST env vars) and returned it
as the HTTP response body — but the warning made it look like a client bug.
Three new shapes in handleAuditInstance:
- 404 → "Built-in audit endpoint not available on this n8n version." (unchanged)
- other status → "Built-in audit failed (HTTP <status>): <reason>"
- no status → "Built-in audit failed (no response from n8n): <reason>"
Also fixed a long-standing nit: the catch block's builtinAuditMs was computed
against totalStart instead of auditStart. Hoisted auditStart so both paths use
the same anchor.
3 unit tests covering each branch.
## #740 — n8n_manage_credentials accepts oAuth2Api + clientCredentials payloads
n8n's upstream Ajv schema for oAuth2Api has a known bug: the if/then/else on
useDynamicClientRegistration uses properties.x.enum to test value, which
evaluates true vacuously when the field is absent — so both then branches
fire simultaneously and there is no payload shape that satisfies the schema
for a plain clientCredentials grant. Reporter (@bwsnwl) hit this on a
Microsoft Graph app-only auth setup.
New applyCredentialDataShims() helper in handlers-n8n-manager.ts:
- Activates only for type === 'oAuth2Api' && grantType === 'clientCredentials'
- Strips useDynamicClientRegistration when present and falsy (root has
additionalProperties: false and doesn't list it)
- Injects sendAdditionalBodyProperties: false and additionalBodyProperties: ''
(grant-type then branch requirement)
- Injects serverUrl: '' ONLY when the DCR branch fires spuriously (DCR is
absent or false) — explicit useDynamicClientRegistration: true callers
are left alone so n8n surfaces real missing-field errors
- Applied symmetrically on both create and update paths
The shim is a hack with a clear sunset condition: remove when n8n fixes the
schema upstream. Comment block documents the bug + each injection.
5 unit tests (positive + negative + DCR-true preservation + non-oAuth2 regression
+ update path symmetry). Verified end-to-end against live n8n: 4 credentials
created + cleaned up; httpHeaderAuth unaffected.
Reporters: @waltho1123-cloud (#736), @bwsnwl (#740).
Conceived by Romuald Członkowski - https://www.aiadvisors.pl/en
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix(handlers-n8n-manager): address Copilot review on PR #759
Three nits from Copilot, all uzasadnione:
1. handleUpdateCredential previously skipped the oAuth2 clientCredentials
shim when the caller omitted `type` (a common partial-update pattern
where users only re-send `data`). The shim's first check is type-based,
so an update without `type` would silently bypass it and re-trigger the
upstream n8n schema bug. Now: when `type` is omitted AND
`data.grantType === 'clientCredentials'` (cheap pre-check), fetch the
existing credential to derive its type before applying the shim. The
extra GET only fires for the specific narrow case where the shim might
apply — other updates skip it.
2. package-lock.json was still on 2.47.14 after the version bump to 2.48.2.
Synced via `npm install --package-lock-only`.
3. Added two unit tests covering:
- update with `type` omitted + clientCredentials data → fetches existing
credential, derives type, applies shim
- update with `type` omitted + non-clientCredentials data → does NOT
fetch (no extra round-trip)
71 unit tests pass; lint clean.
Conceived by Romuald Członkowski - https://www.aiadvisors.pl/en
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 7fc714d commit f6ab3d5
8 files changed
Lines changed: 362 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
10 | 19 | | |
11 | 20 | | |
12 | 21 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
0 commit comments