Skip to content

Fix OData V4 error serialization in generated Python models - #12069

Closed
Libba Lawrence (l0lawrence) wants to merge 1 commit into
microsoft:mainfrom
l0lawrence:l0lawrence-odatav4format-as-dict-conversion
Closed

Libba Lawrence (l0lawrence) wants to merge 1 commit into
microsoft:mainfrom
l0lawrence:l0lawrence-odatav4format-as-dict-conversion

Conversation

@l0lawrence

Copy link
Copy Markdown
Member

Why

Azure ODataV4Format has no as_dict() method. When a generated model materializes nested error details, model.as_dict() can retain those objects, so plain json.dumps(model.as_dict()) fails.

What changed

Convert ODataV4Format to a wire-shaped dictionary at generated as_dict(), SdkJSONEncoder, and _serialize boundaries. The Azure-only conversion handles recursive details and innererror while preserving omitted optional fields and nested nulls; the unbranded flavor remains unchanged. Added focused generated-template regression coverage and a fix changelog entry.

Validation

  • Focused tests: 3 passed (test_odata_v4_serialization.py, with the mock-server parent fixture excluded).
  • Black check and pylint errors-only check passed for the new tests.
  • Full emitter build was blocked by missing tsc in this worktree. Repository formatting could not complete because the TypeSpec Prettier plugin's dist/index.js has not been built.

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 Sep 29, 2026
@pkg-pr-new

pkg-pr-new Bot commented Sep 29, 2026

Copy link
Copy Markdown

Open in StackBlitz

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

commit: 6f61ceb

@github-actions

Copy link
Copy Markdown
Contributor

All changed packages have been documented.

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

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

Convert deserialized OData V4 errors to JSON-compatible dictionaries when serializing generated Python models and request bodies.

@l0lawrence

Copy link
Copy Markdown
Member Author

feels like an azure-core change

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