Skip to content

Fix ResponseAsBool_HeadAsBoolean scenario coverage failing - #4981

Merged
weidongxu-microsoft merged 2 commits into
mainfrom
weidxu/fix-head-as-boolean-scenario
Jul 22, 2026
Merged

Fix ResponseAsBool_HeadAsBoolean scenario coverage failing#4981
weidongxu-microsoft merged 2 commits into
mainfrom
weidxu/fix-head-as-boolean-scenario

Conversation

@weidongxu-microsoft

Copy link
Copy Markdown
Member

Problem

The Azure_ClientGenerator_Core_ResponseAsBool_HeadAsBoolean scenario fails coverage for all languages, even when the client behaves correctly (verified: Java ResponseAsBoolTests assertions pass, but the Spector coverage file reports ... _HeadAsBoolean => fail).

Root cause

The mockapi used passOnSuccess for a two-endpoint scenario where notExists intentionally returns 404 (to exercise the @responseAsBool false path). passOnSuccess sets passCondition: "response-success", which the coverage tracker evaluates as checkAll(x => x.status >= 200 && x.status < 300) — so the 404 endpoint can never pass. passOnCode can't help either, since it forces a single code for all endpoints while this scenario mixes 204 and 404.

Secondary: @route("/not-exists") was nested under the namespace's @route("/exists"), resolving to /exists/not-exists (the @scenarioDoc claimed /not-exists).

Fix

Split into two scenarios:

  • ..._HeadAsBoolean_existspassOnSuccess (HEAD /exists -> 204 -> true)
  • ..._HeadAsBoolean_notExistspassOnCode(404) (HEAD /not-exists -> 404 -> false)

Also corrects the notExists route to /not-exists and regenerates spec-summary.md.

Note: downstream language repos referencing the old scenario name Azure_ClientGenerator_Core_ResponseAsBool_HeadAsBoolean will need to update to the two new names.

@microsoft-github-policy-service microsoft-github-policy-service Bot added the lib:azure-http-specs For issues/prs related to the @azure-tools/typespec-azure-http-specs package label Jul 21, 2026
@weidongxu-microsoft
weidongxu-microsoft marked this pull request as ready for review July 21, 2026 02:49
@azure-sdk-automation

azure-sdk-automation Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

All changed packages have been documented.

  • @azure-tools/azure-http-specs
Show changes

@azure-tools/azure-http-specs - fix ✏️

Fix ResponseAsBool_HeadAsBoolean scenario coverage always failing. Split it into two scenarios (exists and notExists) so the intentional 404 response of notExists is validated with passOnCode(404) instead of passOnSuccess (which requires all endpoints to return 2xx). Endpoint paths are unchanged.

@pkg-pr-new

pkg-pr-new Bot commented Jul 21, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@azure-tools/azure-http-specs@4981

commit: e6104fe

@azure-sdk-automation

Copy link
Copy Markdown
Contributor

You can try these changes here

🛝 Playground 🌐 Website

Split the single HeadAsBoolean scenario into two (exists, notExists) so
the intentional 404 response is validated with passOnCode(404) instead of
passOnSuccess, which required all endpoints to be 2xx. Endpoint paths are
unchanged to avoid downstream generated-code churn.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 192afd5d-4ac7-429d-a37b-c96478337db5
@weidongxu-microsoft
weidongxu-microsoft force-pushed the weidxu/fix-head-as-boolean-scenario branch from 4de7634 to 40c1d21 Compare July 21, 2026 03:26
@weidongxu-microsoft
weidongxu-microsoft added this pull request to the merge queue Jul 22, 2026
Merged via the queue into main with commit a2f733f Jul 22, 2026
43 checks passed
@weidongxu-microsoft
weidongxu-microsoft deleted the weidxu/fix-head-as-boolean-scenario branch July 22, 2026 05:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lib:azure-http-specs For issues/prs related to the @azure-tools/typespec-azure-http-specs package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants