You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "moonming (via GitHub)" <gi...@apache.org> on 2026/07/10 07:38:32 UTC
[PR] fix: no-op edit-save deleted inline upstream health checks [apisix-dashboard]
moonming opened a new pull request, #3423:
URL: https://github.com/apache/apisix-dashboard/pull/3423
## What
Fixes #3414 (**silent data loss**).
Opening a route/service/stream-route whose **inline upstream has health checks**, clicking **Edit**, and clicking **Save without changing anything** silently deleted `upstream.checks`. The green "Edit … Successfully" toast made the loss invisible. Reproduced against a real APISIX before fixing.
## Root cause
The detail pages reset their form with `produceToNestedUpstreamForm`, which wrote the `__checksEnabled` UI flags **nested** under `upstream.` — but `FormSectionChecks` registers and reads those flags at the form **root**. After the reset (triggered by the mount-time background refetch), the root flag read `undefined` → the checks section rendered as "disabled" → its inputs unmounted → `shouldUnregister: true` dropped `upstream.checks` from the PUT body → the Admin API PUT replaced the resource without checks.
## How
- `produceToNestedUpstreamForm` now derives the root-level `__checksEnabled`/`__checksPassiveEnabled` from the nested upstream's checks (`src/components/form-slice/FormPartUpstream/util.ts`)
- `stream_routes/detail.$id.tsx` resets through the producer (it reset with the raw API value, so the flags were never computed there at all)
## Verification — including a RED check
- new regression e2e `e2e/tests/regression/form.noop-edit-preserves-checks.spec.ts` (route + service variants): seeds a resource with checks via the Admin API, **loads the detail page directly** (full page load — the bug only reproduces on a fresh mount), waits for the detail queries to settle (the exact reset that wiped the flags), performs a no-op Edit→Save, then asserts via the Admin API that `upstream.checks` survived
- **verified the spec fails on the unfixed code** (route variant catches the wipe; the PUT body captured during debugging shows the upstream stripped of `checks`) and passes with the fix — the timing subtlety is documented in the spec
- also re-verified manually in a live environment: unfixed → checks GONE after no-op save; fixed → PRESERVED
- `pnpm lint` clean, `tsc -b` clean
--
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: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: no-op edit-save deleted inline upstream health checks [apisix-dashboard]
Posted by "moonming (via GitHub)" <gi...@apache.org>.
moonming commented on PR #3423:
URL: https://github.com/apache/apisix-dashboard/pull/3423#issuecomment-4933161435
Post-push audit came back with **no HIGH findings**; disposition of the rest (8dd04e85):
- **M3 (settle heuristic can race on slow runners)** — addressed: after the GET-settle wait, both variants now assert `getByTestId('checksEnabled')` is checked before clicking Edit. The bug's first visible symptom was this switch reading off, so the discriminator is now deterministic rather than timing-based.
- **M1 (no stream_routes e2e variant)** and **M2 (passive-only regression not covered)** — deliberately left as follow-ups per maintainer bandwidth; both are cheap additions inside `form.noop-edit-preserves-checks.spec.ts` and are listed in the test-gap section of #3417 for anyone picking it up. The stream_routes code path itself is exercised manually and shares the fixed producer.
- **L1 (top-level `if (d.checks)` precedence)** / **L2 (flag-derivation duplicated in two producers)** — valid cleanups, no current caller is affected; noted here for a future refactor.
- **L3 (`rmDoubleUnderscoreKeys` crashes on `null`)** — pre-existing, already tracked as a checkbox in #3417 ("Data-integrity" section).
--
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: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: no-op edit-save deleted inline upstream health checks [apisix-dashboard]
Posted by "moonming (via GitHub)" <gi...@apache.org>.
moonming commented on PR #3423:
URL: https://github.com/apache/apisix-dashboard/pull/3423#issuecomment-4933881136
CI's e2e failure on `routes.crud-all-fields` turned out to be this PR **exposing a second, older bug** that the #3414 wipe had been masking — fixed in f413fc81:
**What CI caught:** after this PR mounts the checks section correctly, editing a route whose checks only configure the *unhealthy* side (exactly what the dashboard's own create flow stores — no `active.healthy`, no `type`) made Save silently do nothing: the hand-written zod schema declared `checks.active.healthy`/`unhealthy` as **required**, while the Admin API treats both as optional. The resolver error sat on a path with no rendered input, so there was no PUT, no toast, and no visible error. On master this never surfaced because the wiped checks section kept those fields unregistered — the data-loss bug was hiding the validation bug.
**Fixes:**
1. `upstreams.ts`: `active.healthy`/`active.unhealthy` → `.optional()`, matching the Admin API (the passive side already was).
2. `services`/`stream_routes` detail pages: `defaultValues` now run through `produceToNestedUpstreamForm` too — when the root flags only appear at reset time, the late-mounting passive section missed the reset values and the passive block was dropped from the PUT (root+service variants of the regression spec both discriminate this now).
3. The regression seed is now deliberately sparse (mirroring UI-stored shape) and asserts the **passive** block survives — which also covers the audit's M2.
Verified locally: the previously failing `routes.crud-all-fields.spec.ts` now passes, plus upstreams/services crud suites and the strengthened regression spec. (`stream_routes` specs can't run against my local backend — stream mode disabled — CI covers those.)
--
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: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: no-op edit-save deleted inline upstream health checks [apisix-dashboard]
Posted by "Yilialinn (via GitHub)" <gi...@apache.org>.
Yilialinn merged PR #3423:
URL: https://github.com/apache/apisix-dashboard/pull/3423
--
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: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org