Skip to content

[http-client-python] Serialize named model query parameters - #12624

Draft
Libba Lawrence (l0lawrence) wants to merge 1 commit into
microsoft:mainfrom
l0lawrence:l0lawrence-python-core-support-fix
Draft

Libba Lawrence (l0lawrence) wants to merge 1 commit into
microsoft:mainfrom
l0lawrence:l0lawrence-python-core-support-fix

Conversation

@l0lawrence

Copy link
Copy Markdown
Member

Summary

Fix one coherent Core-tier standard HTTP scenario group: named-model query expansion.

  • Routes_QueryParameters_QueryExpansion_Standard_model
  • Routes_QueryParameters_QueryExpansion_Explode_model
  • Routes_QueryParameters_QueryContinuation_Standard_model
  • Routes_QueryParameters_QueryContinuation_Explode_model

Preserve the query model's explode flag in the emitter and serialize its wire-name/value pairs rather than passing the generated mapping model through the legacy object serializer. Standard expansion joins individually URL-encoded keys and values with commas; exploded expansion emits separate query parameters. Optional missing properties are omitted, and false, zero, and empty strings are preserved.

Adds synchronous and asynchronous Spector regressions for all four scenarios, plus focused serializer tests for escaping, falsy values, skip-encoding, and missing required input. No coverage metadata or existing expectations are changed.

Dashboard evidence and freshness

Discovery on 2026-11-19 used https://typespec.io/can-i-use/http/ and its deployed /_astro/index.C7Pug40E.js, not the Azure Python emitter:

  • The deployed storage helper uses the public coverages container. It reads the generator index, first probes reports/<version>.json, then falls back to reports/<version>/standard.json. The legacy report for the indexed version was absent; the standard report was successfully obtained.
  • Current manifest: @typespec/http-specs 0.1.0-alpha.46, commit e06f6b34fdad9d7f49bfc084a598b03c60684e9a.
  • Python index: 0.28.3.
  • Selected Python standard report: selected only the suite whose scenariosMetadata.packageName is @typespec/http-specs; spec version 0.1.0-alpha.36, report date 2026-04-28, generator/spec commit 07e6c7fb6a6f6c32583bdbabd7be8b8a17f58398. That historical commit is not available in this checkout or through the current microsoft/typespec commit endpoint.
  • All four IDs are not-reported against the current manifest, so the report alone was not treated as evidence of missing behavior.
  • Applied only the live tier configuration from https://azure.github.io/typespec-azure/can-i-use/http/ using its deployed matching semantics: exact IDs take precedence over anchored wildcard patterns, then the default tier. The configuration defaults to Core and has 73 Backlog rules; none matches these four IDs. No Azure Python coverage was used.

The starting checkout was b317c506c01f3a7226ae34e1c1d59fdb5fe2ffa6, with Python emitter 0.40.1 and http-specs 0.1.0-alpha.46. The manifest's routes/main.tsp location was inspected in the checkout, and the installed standard spec used for generation was verified byte-equivalent after newline normalization. The named-model scenarios were added on 2026-10-07, after the published report. Earlier boolean and duration leads already pass against the current emitter and were skipped.

Open microsoft/typespec PRs and identifiable pending Python automation sessions were checked before selection; no overlapping named-model query fix was found.

Reproduction and fix

Generating the current routes SDK succeeds, but calling any of the four operations with the public ExpandParameters(field="status", value="active") type failed before sending HTTP:

AttributeError: 'ExpandParameters' object has no attribute 'is_xml_model'

The request builder previously called _SERIALIZER.query("param", param, "ExpandParameters"); the emitter also discarded explode for non-array parameters. Both causes are fixed. The new Spector tests were run before implementation and all eight sync/async cases failed with that error.

Checks

Run from the isolated automation worktree:

  • npm run build and npm run test:emitter in packages/http-client-python: passed, 75 emitter tests.
  • Targeted routes regeneration through the existing compile(NodeHost, ...) API using the local emitter and PYTHONPATH=generator: passed.
  • Pytest covering test_query_model_serialization.py, test_content_type_optional_body.py, test_string_literals.py, and both sync/async test_routes files: 361 passed. The local harness redirected the route clients and fixture to this session's own standard Spector server on port 3107, leaving an existing port-3000 server untouched.
  • npm run lint: passed (Oxlint and generator Pylint).
  • Pylint on the regenerated unbranded routes SDK: passed.
  • npm run format, npm run format:check, and Black checks on the three changed Python test files: passed.
  • Actual request URLs were checked for escaped commas and ampersands: standard ?param=field,a%2Cb,value,c%26d; exploded ?field=a%2Cb&value=c%26d.
  • git diff --check: passed.

Dependency setup initially encountered a test-tool feed error and the formatter needed its repository build dependencies; these were resolved before the passing checks above. No dependency manifests or lockfiles were changed.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@microsoft-github-policy-service microsoft-github-policy-service Bot added the emitter:client:python Issue for the Python client emitter: @typespec/http-client-python label Nov 19, 2026
@pkg-pr-new

pkg-pr-new Bot commented Nov 19, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@typespec/http-client-python@12624

commit: ecd45f6

@github-actions

Copy link
Copy Markdown
Contributor

All changed packages have been documented.

  • ✅ @typespec/http-client-python
Show changes

@typespec/http-client-python - fix ✏️

Serialize named model query parameters using form-style expansion, including exploded properties and query continuation routes.

@github-actions

Copy link
Copy Markdown
Contributor

Python emitter diff

Baseline gh:b317c506c01f3a7226ae34e1c1d59fdb5fe2ffa6 vs this PR.

Diff summary: 223 file(s), +4316 / -8

Rendered diff: inline on the run summary, or the emitter-diff-html artifact.

Informational check (eng/emitter-diff); does not block the PR.

@azure-sdk-automation

Copy link
Copy Markdown

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:client:python Issue for the Python client emitter: @typespec/http-client-python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant