Skip to content

[python] Python Integration Mock API Tests fail due to azure-http-specs version skew (pinned alpha.43 mock vs client regenerated from typespec-azure main) #11348

Description

@msyyc

Summary

The Python Integration → Mock API Tests check (workflow .github/workflows/python-integration.yml) can fail with a body-validation error that is unrelated to the PR under test, due to a version skew between:

  • the azure-http-specs mock server (pinned to @azure-tools/azure-http-specs@0.1.0-alpha.43 via http-client-python), and
  • the generated client, which is regenerated from the Azure/typespec-azure main .tsp source checked out by the workflow.

When the spec source on typespec-azure main is newer than the pinned alpha.43 bundle, the client and the mock disagree and the tests fail.

Observed failure

Seen on PR #11272 (a change that only touches content-type header serialization, unrelated to ARM common-properties):

Run: https://github.com/microsoft/typespec/actions/runs/29883405836/job/88810730906

FAILED mock_api/azure/test_azure_arm_commonproperties.py::test_arm_resource_identifiers_create_or_replace
FAILED mock_api/azure/test_azure_arm_commonproperties.py::test_arm_resource_identifiers_get
FAILED mock_api/azure/asynctests/test_azure_arm_commonproperties_async.py::test_arm_resource_identifiers_create_or_replace
FAILED mock_api/azure/asynctests/test_azure_arm_commonproperties_async.py::test_arm_resource_identifiers_get

azure.core.exceptions.HttpResponseError: (None) Body provided doesn't match expected body:
  at $.properties: Key count mismatch: expected 4 but got 5. extra: [armIdWithGroupScope]

The generated client sends 5 properties (including armIdWithGroupScope); the mock server expects 4.

Root cause

The Build & Regenerate job pins only the compiled mock /dist to the http-client-python-resolved alpha.43, but the client is regenerated from the freshly checked-out typespec-azure main .tsp source:

  • Mock server dist is overwritten with the pinned alpha.43 bundle:
    - name: Use pinned http-specs versions
    run: |
    rm -rf core/packages/http-specs/dist
    cp -r core/packages/http-client-python/node_modules/@typespec/http-specs/dist core/packages/http-specs/dist
    rm -rf packages/azure-http-specs/dist
    cp -r core/packages/http-client-python/node_modules/@azure-tools/azure-http-specs/dist packages/azure-http-specs/dist
  • Client is regenerated right after, from the checked-out typespec-azure source:
    - name: Regenerate
    run: pnpm run regenerate
    working-directory: packages/typespec-python

The pinned version:

Meanwhile, armIdWithGroupScope was added to both the model and the mock in typespec-azure main by PR Azure/typespec-azure#4891 (2026-07-15), which is newer than the alpha.43 bundle:

So within typespec-azure main the spec is internally consistent (model and mock both have 5 fields). The skew is introduced only by the workflow, which mixes:

Impact

Any PR that only touches packages/http-client-python/** (which is what triggers this workflow) can get a red Mock API Tests check it did not cause, whenever typespec-azure main advances an azure-http-specs/http-specs spec beyond the pinned alpha.43 bundle. This blocks otherwise-green PRs (e.g. #11272).

Suggested fixes (pick one)

  1. Bump the pin in packages/http-client-python/package.json for @azure-tools/azure-http-specs (and @typespec/http-specs) to a version that includes Add built-in service group extension support Azure/typespec-azure#4891, so the mock dist matches the spec source used for regeneration.
  2. Regenerate the client from the same pinned bundle used for the mock, instead of from the checked-out typespec-azure main source — i.e. make both sides use one source of truth in python-integration.yml.
  3. Do not pin the mock dist to the http-client-python-resolved version — build/use the mock from the same checked-out typespec-azure source used for regeneration, keeping client and mock in lockstep.

Option 2 or 3 removes the class of failure entirely; option 1 fixes the current occurrence.

Notes

  • The http-client-python package's own unit/e2e tests (typespec - ci on Azure DevOps) are unaffected and pass; this is specific to the downstream typespec-python (Azure/typespec-azure) Mock API e2e run wired up by python-integration.yml.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingemitter:client:pythonIssue for the Python client emitter: @typespec/http-client-python

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions