lxbme opened a new pull request, #3429: URL: https://github.com/apache/apisix-dashboard/pull/3429
**Why submit this pull request?** - [x] Bugfix - [ ] New feature provided - [ ] Improve performance - [ ] Backport patches **What changes will this PR take into?** Two small, independent hardening fixes from the tracking issue #3417 (Error handling / resilience), one commit each. They share a theme but touch disjoint files, so they ship together to keep review overhead low. A third candidate originally planned for this PR (the settings admin-key refetch storm) turned out to be already fixed upstream by #3422 and is not included. ### Commit 1: guard the stream_routes error component against bodyless 400s (#3417 item 2, residual) `StreamRoutesErrorComponent` special-cases 400 responses to show APISIX's `error_msg` (the "stream mode is disabled, can not add stream routes" hint), but dereferenced `err.response?.data.error_msg` — the optional chain guarded `response`, not `data`. A 400 whose body is empty or non-JSON (proxy/gateway truncation) rendered an empty error area, and for nullish `data` shapes the error component itself threw a TypeError, crashing into the root boundary. Five stream_routes routes share this component. Fix: guard `data` and fall back to the axios error message, so the error area is never blank. The `error_msg` branch is untouched — verified manually by disabling `proxy_mode` stream on a live APISIX: the disabled-mode hint renders exactly as before. ### Commit 2: degrade invalid pagination search params to defaults (#3417 item 8) `pageSearchSchema` accepted any string for `page`/`page_size` and transformed it with `Number()`, so `?page=abc` sent `page=NaN` to the Admin API; inputs that failed the union (e.g. duplicated params parsed as arrays, `?page=1&page=2`) threw a ZodError out of `validateSearch` and crashed the list page into the error boundary. Hand-edited URLs, stale bookmarks, and external links can all produce these shapes. Fix: `z.coerce.number().int().min(1).catch(default)` — every invalid shape (non-numeric, arrays, zero/negative, floats) degrades gracefully to the first page instead of failing. Inferred types are unchanged and valid URL params keep working, which the existing pagination helpers across the list suites pin. ### Tests - `e2e/tests/regression/stream-routes.error-400-no-body.spec.ts`: fulfills the list GET with a bodyless 400 and asserts a visible error message renders (axios fallback text) with no crash. Written first and verified failing against the old behavior (empty error area). - `e2e/tests/regression/pagination.invalid-search-params.spec.ts`: `?page=abc&page_size=xyz` renders the list normally and the outgoing request carries `page=1&page_size=10` (asserted via request capture); duplicated `page` params render without crashing. Both written first and verified failing. Also ran locally: stream_routes CRUD suites, five list-page suites (whose pagination helpers assert valid URL params still switch pages), and the full `e2e/tests/regression/` folder — all green. Manual verification on the production-like build covered the URL matrix (`abc`, duplicates, `0`, negatives, valid `page=2`) and the stream-disabled hint path. **Related issues** Part of #3417 (items: "stream_routes custom error handler unguarded dereference" under item 2, and "invalid pagination search params" item 8, both under Error handling / resilience). Does **not** 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? - [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]
