Repository navigation
[http-client-python] Honor void response replacements - #12651
Draft
Libba Lawrence (l0lawrence) wants to merge 1 commit into
Draft
Libba Lawrence (l0lawrence) wants to merge 1 commit into
Libba Lawrence (l0lawrence) wants to merge 1 commit into
Conversation
Co-authored-by: Copilot App <[email protected]>
commit: |
Contributor
|
All changed packages have been documented.
Show changes
|
Contributor
Python emitter diffBaseline Diff summary: 2 file(s), +12 / -38 Rendered diff: inline on the run summary, or the emitter-diff-html artifact. Informational check (eng/emitter-diff); does not block the PR. |
|
You can try these changes here
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix one verified Core-tier Spector gap in
@typespec/http-client-python: basic methods with an intentional void response replacement now returnNone, rather than deserializing the original service response into a model. Keep the service status, headers, and JSON response on the wire unchanged. Ordinary basic responses and the separately unsupported bytes replacement are not changed.Exact Spector coverage
Azure_ClientGenerator_Core_ResponseReplacement_voidResponsenot-implemented; Core by the current default tier, with no matching Backlog exact/wildcard rule. The standard dashboard does not include this Azure suite/scenario.packages/http-client-python/tests/mock_api/azure/test_response_replacement.pyandpackages/http-client-python/tests/mock_api/azure/asynctests/test_response_replacement_async.py: normal sync/async calls returnNone; aclscallback receives aNonedeserialized value while the raw response still has status 200 and JSON{"name":"widget"}.This is the only scenario for which this PR adds Python Spector coverage. It does not claim support for
Azure_ClientGenerator_Core_ResponseReplacement_bytesResponse.Verified cross-language comparison
packages/http-client-csharp/generator/TestProjects/Spector.Tests/Http/Azure/ClientGeneratorCore/ResponseReplacement/ResponseReplacementTests.cs, introduced by #12340. ItsVoidResponseandVoidResponseAsyncassert the untypedClientResultruntime type, HTTP 200, and the exact raw JSON text. Python provides equivalent sync/async discard-body behavior and raw-response access, but returnsNoneinstead of an untyped result wrapper; itsclscallback verifies the parsed raw JSON rather than comparing its textual formatting.packages/http-client-java/generator/http-client-generator-test/src/test/java/azure/clientgenerator/core/responsereplacement/ResponseReplacementTests.java, added with regenerated coverage in #12540.testVoidResponseis a sync Spector client invocation with no explicit return-value or raw-response assertions. The Python tests additionally assertNone, status/body preservation, and async behavior. Java's separate bytes test is not parity evidence for the void scenario and is not included in this PR's coverage claim.Fresh dashboard evidence and version comparison
Both deployed dashboards were inspected, including their hydrated configuration and deployed JavaScript, rather than assuming report paths. They read
https://typespec.blob.core.windows.net/coverages/, resolve<generator>/index.json, try legacyreports/<version>.jsonfirst, then the mode-specific report. The legacy reports were absent and both selected reports were obtained. Report suites were matched to manifests byscenariosMetadata.packageName; missing scenario entries were treated as leads, not proof of unsupported behavior.@typespec/http-client-python/reports/0.28.3/standard.json, generator commit07e6c7fb6a6f6c32583bdbabd7be8b8a17f58398; HTTP suite0.1.0-alpha.36, same commit.@azure-tools/typespec-python/reports/0.63.12/azure.json, generator commita5cc5a36512716e89d7578e4cda3b721580164b4; Azure suite0.1.0-alpha.47, same commit; HTTP suite0.1.0-alpha.46, commit123e997958ced3b632caa0a4486e306d1487ca82.0.1.0-alpha.46, commite06f6b34fdad9d7f49bfc084a598b03c60684e9a(verified ancestor of this checkout).0.1.0-alpha.47, commit9f3187901c0ef5015eb0d8eb4b0151166cd79135.1549a46bdb9b4f8dbaa45199807d927f66f1a423; Python emitter0.40.1, pinned HTTP specs0.1.0-alpha.46and Azure specs0.1.0-alpha.47. No dependency versions were changed. The report commits differ from the current manifests; the standard report's HTTP version also predates the pinned suite.The Azure dashboard's live tier rules were applied to scenarios from both dashboards: exact rules take precedence over anchored
*wildcard rules, then the configured default (Core). Core candidate leads were merged by scenario ID. Open Microsoft TypeSpec PRs and identifiable pending Python automation sessions were checked; named-model query scenarios already tracked by #12624 and policy-skipped specs were excluded from selection.Reproduction and root cause
Read the manifest-located, pinned Azure spec and its
client.tspoverride andmockapi.tsunderpackages/http-client-python/node_modules/@azure-tools/azure-http-specs/specs/azure/client-generator-core/response-replacement/.Before the fix, both new pytest tests failed because
void_response()returnedWidget(name="widget")instead ofNone. A separate sync reproduction against an isolated Spector server serving these pinned dependencies on port 3107 failed identically. The emitter always chose the underlying HTTP body type for basic methods, ignoring the overridden method's absent response type.The fix honors an absent response type on overridden basic methods, retaining the original wire response metadata. The emitter unit regression verifies omitted response type with HTTP 200 and
application/jsonpreserved.Checks
Passed:
npm run buildinpackages/http-client-python.npm run test:emitter: complete emitter suite, 76 tests.npx tsc --noEmit -p .\emitter\tsconfig.json.tests/generated/azure/responseto avoid Windows long-path failures in the usual fixture directory.python -m pyteston the two new sync/async Spector files: 2 passed (--asyncio-mode=auto).Noneand raw status/body assertions.npm run format,npm run format:check,npm run lint -- --emitter, and Black checks for both added Python tests.pnpm formatandgit diff --check.Only targeted Spector clients were generated; the full generated-client flavor matrix was not run. Generated clients and coverage output are not committed, and no coverage metadata or existing assertions were weakened.