lxbme opened a new pull request, #3432:
URL: https://github.com/apache/apisix-dashboard/pull/3432

   **Why submit this pull request?**
   
   - [x] Bugfix
   - [ ] New feature provided
   - [ ] Improve performance
   - [ ] Backport patches
   
   **What changes will this PR take into?**
   
   Part of #3417 (Data-integrity section): "`rmDoubleUnderscoreKeys` recurses 
into `null` (`typeof null === 'object'`) and throws — runs *before* the 
null-cleaner in `pipeProduce`, so a plugin config containing `null` crashes the 
submit."
   
   `typeof null === 'object'`, so the `__`-key cleaner recursed into null 
values and threw `TypeError: Cannot convert undefined or null to object` at 
`Object.keys(null)`. It runs first in `pipeProduce` — before the null-cleaner 
stage — so a `null` anywhere in a submit draft crashed the submit of every 
resource built on `pipeProduce` (routes, services, upstreams, consumers, …).
   
   Severity, verified on a live gateway:
   
   - The Admin API **accepts** nulls inside plugin configs (`{"key-auth": 
{"custom_note": null}}` → 201, stored verbatim), so such a resource can exist — 
and then **cannot be edited from the dashboard at all**: every Edit → Save dies 
before the PUT is built.
   - The failure is **completely silent**: no request is sent, and the error 
toast layer lives in the axios interceptor, which never runs (there is no 
`MutationCache.onError` either — that is a separate open item of #3417). The 
only trace is an unhandled rejection in the console.
   - The same crash hits nulls typed into the plugin JSON editor on create 
(valid JSON that the editor accepts).
   
   **Fix.** One guard: skip null values in the recursion (they are the 
downstream null-cleaner's job). Resulting semantics are the pipeline's existing 
ones, verified empirically: a null member alongside other keys is stripped by 
the null-cleaner; a plugin config consisting only of nulls is emptied by the 
deep-clean and then restored verbatim (null included) by 
`produceRestoreEmptyPlugins` — the Admin API accepts both shapes. No semantic 
change for null-free drafts.
   
   **Tests** (both red on the unfixed build at the intended assertions, green 
after):
   
   - Unit `src/utils/producer.test.ts`: no-throw on nulls, nulls left in place, 
`__`-keys still removed at every depth, `pipeProduce` end-to-end no-throw (the 
crash was the repo's first unit-testable regression of this producer).
   - E2E regression `form.plugin-config-null-submit.spec.ts`: a route seeded 
with `{"key-auth": {"custom_note": null}}` survives Edit → Save — success toast 
shown, PUT actually fired (request counter), plugin present after round-trip.
   
   Blast radius: full local e2e suite — 171 passed; 2 failures are documented 
environment items unrelated to this change (`stream_routes.show-disabled-error` 
cannot run outside the repo's own compose project; 
`plugin_metadata.crud-all-fields` is a pre-existing Monaco read-back race that 
reproduces on pristine master at the same rate, with the stored data verified 
correct via concurrent Admin API polling). Unit tests 14/14, lint and build 
clean. Also verified compatible with open PR #3431 via an octopus merge of both 
branches onto master: regression folder 43/43 green on the merged tree.
   
   **Related issues**
   
   Part of #3417 
   
   **Checklist:**
   
   - [x] Did you explain what problem does this PR solve? Or what new features 
have been added?
   - [x] Have you added corresponding test cases?
   - [ ] Have you modified the corresponding document? (no user-facing document 
covers the submit pipeline)
   - [x] Is this PR backward compatible? If it is not backward compatible, 
please discuss on the mailing list first


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to