Centralise payload conversion utilities#200
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| convert_value(key_type, raw_key) | ||
| if key_type not in {Any, object} | ||
| else raw_key | ||
| ) | ||
| result[str(key)] = convert_value(value_type, raw_value) |
There was a problem hiding this comment.
Preserve dictionary key types during conversion
The mapping branch of convert_value coerces every converted key to a string (result[str(key)] = …) even when the target type specifies non‑string keys. For annotations such as Dict[int, Foo] or Dict[Enum, Bar] the integer/enum key is computed correctly but then immediately stringified, so callers receive a Dict[str, …] instead of the requested type. This silently breaks code that relies on integer or enum lookups and differs from the previous decoders that preserved key types. Only convert to string when the requested key type is unconstrained; otherwise keep the converted key’s native type.
Useful? React with 👍 / 👎.
Summary
Testing
Codex Task