lxbme opened a new pull request, #3435: URL: https://github.com/apache/apisix-dashboard/pull/3435
**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), two widget/type-mismatch items plus a silent data-loss bug discovered while fixing the second one. Three commits, one root cause each: **1. `checks.active.http_request_headers` rendered with the Labels widget (`d8157e7`)** The field is `array<string>` (raw header lines, matching the Admin API) but was rendered with the Labels widget, which expects an object. Both directions were broken: stored header lines displayed as an empty field (the widget's array guard returns `[]`), and typed input produced an object that failed the zod array schema on submit — the field was unusable. Now a `FormItemTagsInput`, the same control the sibling `http_statuses` fields already use. **2. `ssls.client.skip_mtls_uri_regex` rendered as a boolean Switch (`1c0d99c`)** Same class: the field is `array<string>` (URI regexes) but was rendered as a Switch. A stored regex list displayed as a meaningless "on" toggle with the values invisible, and toggling wrote a boolean that failed the array schema. Also now a `FormItemTagsInput`. **3. Edit-save silently deleted the SSL's mTLS client block (`997f608`)** Found while writing the e2e for item 2: on master, opening an SSL that has a `client` block, clicking Edit and saving **silently deletes the whole `client` block** — the PUT succeeds, the success toast shows, and mTLS client verification is gone. (The existing ssls crud spec's "click Cancel instead of Save" workaround hints at this area's fragility.) Root cause, probe-verified: the SSL detail page created its form **without creation-time `defaultValues`** and populated it only through a later `form.reset()`. Under `shouldUnregister: true`, react-hook-form's `useController` mount effect (v7.56.1) overwrites a field's `_defaultValues` entry from `_options.defaultValues` — i.e. with `undefined` — so every controlled field that mounts **after** that reset loses its re-seed source. The client section is exactly that (it mounts once the reset sets `__clientEnabled`), so the unmount/remount around toggling Edit dropped the values with nothing to restore from: `client.ca` measured 1333 chars in view mode and `undefined` immediately after clicking Edit, while root-level fields that registered before the reset (e.g. `cert`) survived. Fix: pass `produceToSSLForm(sslData)` as creation-time `defaultValues` (the data is synchronously available via `useSuspenseQuery`) — the exact pattern the routes/services/stream_routes detail pages already use, and the same bug class as #3414. A survey of all detail pages confirmed ssls was the only remaining page combining `shouldUnregister` + reset-only population + a conditionally-mounted controlled section. **Tests** (each red on the unfixed build at the intended assertion, green after): - `upstreams.http-request-headers-field.spec.ts` — stored header lines visible, typed line round-trips to storage as an array member. - `ssls.skip-mtls-uri-regex-field.spec.ts` — stored regexes visible as tags, typed regex round-trips; the private key must be re-entered before saving because the Admin API never returns it (pre-existing, same as the crud spec). - `ssls.noop-edit-preserves-client.spec.ts` — a no-op Edit → Save preserves `client.ca`, `client.depth` and `client.skip_mtls_uri_regex` verbatim (red reproduced the silent deletion: save "succeeded" with `client` gone from storage). Blast radius: full local e2e suite — **173 passed**; the only 2 failures are documented environment items unrelated to this change (a Monaco read-back race that reproduces on pristine master, and `stream_routes.show-disabled-error`, which cannot run outside the repo's own compose project). Unit tests, lint and build clean. **Related issues** Part of #3417 (please do not auto-close the tracking issue) **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 these form fields) - [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]
