Repository navigation
Conversation
There was a problem hiding this comment.
No issues found across 6 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Shadow auto-approve: would auto-approve. Fixes Python SDK serialization of unrecognized open enum values by adding an explicit serializer that preserves python-mode values and emits plain str/int in JSON, with new tests covering enum-scalar unions; bounded bug fix with tests.
View guided diff | Turn on auto-fix | Re-trigger cubic
UnrecognizedStr and UnrecognizedInt had no serialization schema, so dumping a model holding an unknown open enum value emitted Pydantic serialization warnings. In an optional nullable open enum field, the value was serialized by the Unset member of the union and then dropped from the output, so the request body omitted it. Give both types an explicit serializer: Python-mode dumps return the original object, JSON-mode dumps return a plain str or int, and values of any other type are declined so union serialization tries the remaining members.
e86efdc to
dce293e
Compare
There was a problem hiding this comment.
0 issues found across 5 reviewed files. 1 file intentionally excluded from review.
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Shadow auto-approve: would auto-approve. Adds explicit serialization for unrecognized open enum values in the Python SDK so dumps emit plain str/int without Pydantic warnings and unknown values survive in nullable union fields; a focused, tested template bug fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
Generator Snapshot Testing
Snapshot results: https://github.com/speakeasy-api/openapi-generation-snapshots/issues/134#issuecomment-6369044276 Snapshot results are summarized above. Additional run context is linked for maintainers with access. |
Why
UnrecognizedStrandUnrecognizedInthold values of open enums (x-speakeasy-unknown-values: allow) that the SDK does not know. They had no serialization schema, so:Unsetmember of the union and then dropped:{"stringOrNull": "future"}was sent as{}.This affects every Python SDK with open enums and needs no configuration.
What changed
type(...) is UnrecognizedStrstill holds;strorint;PydanticSerializationUnexpectedValue, so union serialization moves on to the remaining members.open-enum-scalar-unionsprimary fragment: an open string or integer enum combined withnumber,booleanornull. Thenumberandbooleancases guard that values of other types still keep their JSON type now that the enum types serialize themselves.types/basemodel.pychanges.Stack
preserveUnknownFieldsmodelSerializationMethodsTogether these contain the change from #133, split into two fixes and two independent options.
Testing
TARGET=primary make test-pythonv2: 679 passed, including the new open-enum cases with warnings raised as errors.basemodel.py, the unknown-value cases fail: two on warnings, andstringOrNullserializes to{}.TARGET=review make build-pythonv2: integrity validation passes; onlytypes/basemodel.pyandgen.lockchange.git diff --checkpasses.Public-safety check
.claude/skills/public-repo-communication/SKILL.md).git diff --check.