ITADN

test: add fixture-based regression guard for guardOptionalQueryParams

#843Openalexquincy 创建于 2026-04-24
kind/enhancement
A
alexquincycommented
### Problem - The runtime fix for unguarded queryArg.X accesses in generated RTK clients (PR [#842](https://github.com/layer5io/meshery-cloud/issues/842)) is a post-processor in build/generate-rtk.js. It works, but it has no assertion-level safety net: - No unit/fixture test for guardOptionalQueryParams itself. The bracket-notation gap found during [#842](https://github.com/layer5io/meshery-cloud/issues/842) review (reviewers flagged queryArg["type"] / queryArg["class"] not being handled) was caught by review bots, not by a test. A third access form slipping through in the future would likely go unnoticed the same way. - The only self-check is a log-only canary: if the post-processor makes zero rewrites on a file, it logs "no guardable queryArg accesses found... codegen output shape has changed." It doesn't fail the build. A silent partial miss (the regex still matches some forms but misses a newly-introduced form) wouldn't even trip the canary. CI checks on the schemas repo validate the OpenAPI source (Blocking schema validation, Full schema audit, Consumer audit report). None of them assert anything about the shape of the generated TS. ### Why it matters @rtk-query/codegen-openapi is vendored upstream and we've already seen its output shape shift once (the v1.2.0 regression that drove [#842](https://github.com/layer5io/meshery-cloud/issues/842)). The post-processor is our only defense, and it's currently defended by "we'll notice in review if someone files a PR that breaks it." That held this round; it won't always. ### Proposed fix 1. Add a fixture test (jest or a small standalone Node script under build/__tests__/ or build/test/) that: 1. Feeds a small OpenAPI fragment into the generator (one endpoint with an all-optional *ApiArg, including one dot-access param and one reserved-word bracket-access param). 1. Runs make generate-rtk (or invokes generate-rtk.js directly). 1. Asserts the generated output contains no bare queryArg.X or queryArg["X"] inside any params: { ... } block - only optional-chain forms. 1. Promote the zero-rewrite canary from logger.warn to process.exit(1) when an endpoint's *ApiArg has all-optional fields but no rewrite was applied for it. Current log-only behavior hides the exact failure mode the post-processor exists to prevent. ### Acceptance criteria 1. New test fails on a deliberately broken guardOptionalQueryParams (delete the bracket-regex pass and watch it fail). 1. New test runs in CI (or as part of make generate-rtk's existing flow, gated by exit code). 1. Canary is fail-loud, not warn-and-continue, for the all-optional-ApiArg case. --- ### Contributor [Guides](https://docs.meshery.io/project/contributing) and [Handbook](https://meshery.io/community/handbook) - 🛠 [Meshery Build & Release Strategy](https://docs.meshery.io/project/contributing/build-and-release) - 📚 [Instructions for contributing to documentation](https://github.com/meshery/meshery/blob/master/CONTRIBUTING.md#documentation-contribution-flow) - Meshery documentation [site](https://docs.meshery.io/) and [source](https://github.com/meshery/meshery/tree/master/docs) - 🎨 Wireframes and designs for Meshery UI in [Figma](https://www.figma.com/file/SMP3zxOjZztdOLtgN4dS2W/Meshery-UI) - 🙋🏾🙋🏼 Questions: [Discussion Forum](http://discuss.meshery.io) and [Community Slack](https://slack.meshery.io)
0 条评论