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

   **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): "Inline upstream 
`name`/`desc`/`labels` are unconditionally `delete`d on submit while the form 
renders inputs for them — user input silently discarded; API-created values 
lost on any edit-save."
   
   The inline upstream section of the route / service / stream-route forms 
renders editable Name, Description and Labels inputs (`FormPartBasic` under the 
`upstream` name prefix), but `produceRmEmptyUpstreamFields` unconditionally 
deleted `upstream.name`, `upstream.desc` and `upstream.labels` from every 
submit body (introduced in #3277, no rationale recorded). Both directions lose 
data silently:
   
   - values stored through the Admin API are erased by any dashboard edit-save 
of the parent resource — including a no-op Edit -> Save;
   - values typed into those inputs on the add page are discarded while the 
save reports success.
   
   Verified against a live gateway before changing anything: the Admin API 
accepts and stores non-empty `name`/`desc`/`labels` on an inline upstream (HTTP 
201), so the deletion is not an API-compatibility workaround.
   
   **Fix.** The deletes now only strip *empty* values (`''` name/desc, empty 
`labels` object) instead of all values. Keeping the empty-guard rather than 
removing the deletes outright is deliberate: the Admin API rejects `name: ""` 
with 400 ("string too short, expected at least 1"), and the stream_routes 
create path does not run the deep empty-cleaner (`pipeProduce`), so a 
typed-then-cleared name would otherwise reach the API and fail the save. 
Clearing a previously stored value in edit mode still removes it (PUT is 
full-replace), with no error.
   
   **Tests.** New regression spec `form.inline-upstream-basic-fields.spec.ts` 
(red on the unfixed build at the exact data-loss assertions, green after):
   
   1. a route seeded via the Admin API with inline upstream name/desc/labels 
survives a no-op Edit → Save with all three fields intact;
   2. name/desc typed into the add page's upstream section are actually stored.
   
   Note for reviewers: the spec fills the upstream Description input directly 
instead of passing `desc` to `uiFillUpstreamRequiredFields` — that helper 
accepts a `desc` parameter but never fills it (7 existing call sites pass it, 
silently ignored). Fixing the helper would change the fixtures of those 7 
specs, so it is left for a separate test-gap PR.
   
   Blast radius: routes / services / stream_routes / upstreams / hot-path 
suites plus the regression folder — 76 passed; the 3 local failures are 
pre-existing environment items unrelated to this change 
(`stream_routes.show-disabled-error` cannot run outside the repo's own compose 
project; one Monaco render race and one late-serial-run load flake, both green 
on isolated reruns, stream_routes additionally green on 3× repeat). Unit tests 
10/10, lint and build clean.
   
   **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 this form behavior)
   - [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