Preserve required argument order in errors - #3645
Conversation
b9e4a11 to
5eba6f8
Compare
5eba6f8 to
24463f5
Compare
💡 Codex ReviewLine 20 in 5eba6f8 Changing AGENTS.md reference: AGENTS.md:L45-L48 ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Summary
required_argsvariant's declaration order when listing missing argumentsWhy
The single-variant error path currently computes missing arguments with a set difference. Set iteration depends on Python's randomized hash seed, so an identical invalid SDK call can list parameters in a different order across processes. For example, the same declaration produced both
'model', 'messages' or 'stream'and'messages', 'stream' or 'model'under differentPYTHONHASHSEEDvalues.Filtering the declared variant in place makes the message deterministic and keeps it aligned with the method signature.
Validation
PYTHONHASHSEEDvaluespython -m pytest -q -n 0 tests/test_required_args.py tests/test_utils tests/test_models.py(197 passed)ruff check .ruff format --check .mypy src/openai/_utils/_utils.py