LiteSun commented on issue #3395:
URL:
https://github.com/apache/apisix-dashboard/issues/3395#issuecomment-6190164488
I re-checked this against **production builds**, and the bug is still there
on `master` — the earlier "already gone on master" result was an artifact of
how the dashboard was run.
**What the form actually sends**
The Route/Service/Stream Route forms always render the inline upstream
section, and its Select/Switch widgets register a value the moment they mount.
With the Add Route form filled with only Name + URI + `public-api: {}`, a plain
`vite build` of `master` (713803e3 today; c8d3466d, the build shipped inside
APISIX 3.17.0, behaves the same) POSTs:
```json
{"uri":"/…","upstream":{"scheme":"http","type":"roundrobin","hash_on":"vars","pass_host":"pass","tls":{"verify":false},"discovery_args":{}},"enable_websocket":false,"priority":0,"status":1,"name":"…","plugins":{"public-api":{}}}
```
and the Admin API answers `400 invalid configuration: property "upstream"
validation failed: value should match only one schema, but matches none` (an
upstream needs `nodes` or discovery). The same happens on a no-op Edit → Save
of a plugins-only route created through the Admin API, so the API workaround
only covers creation.
The dashboard embedded in APISIX 3.16.0 is commit bbe05ad9 (3.17.0:
c8d3466d); both reproduce identically, 3.16 additionally drops the `public-api:
{}` entry (#3277 era).
**Why it looked fixed**
`vite dev` and the e2e image both run **development React** (the e2e
Dockerfile builds with `NODE_ENV=test`, which makes Vite bundle the development
build). Under `<StrictMode>` the double-invoked controller effects run
react-hook-form's `shouldUnregister` cleanup, which wipes those mount-time
values from the form state again, so the dev request body is just `{"uri": …}`.
The same `master` with `<StrictMode>` removed, or any production build, sends
the upstream object above. That also means the existing e2e suite could not
catch this class of bug (e.g. the `services … neither` case in #3447 passes in
CI only for that reason).
**Fix**
PR #3477: the shared `produceRmEmptyUpstreamFields` producer now drops an
inline upstream that holds nothing but the widgets' mount-time defaults
(anything the user touched is still sent as-is for the Admin API to validate),
with unit tests plus an e2e regression for both the add and the edit path. The
e2e image is switched to `pnpm build --mode test` so the tests run against
production React (the Monaco test seam is keyed on the Vite mode instead of
`NODE_ENV`).
Side note: the `required` prop on `FormItemNodes` renders nothing — Mantine
only draws the asterisk inside a `label`, and none is passed — so there is no
asterisk to clean up (checked the DOM of the routes/services/upstreams add
pages).
--
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]