Skip to content

Preserve required argument order in errors - #3645

Open
tandede wants to merge 1 commit into
openai:mainfrom
tandede:fix-required-args-order
Open

Preserve required argument order in errors#3645
tandede wants to merge 1 commit into
openai:mainfrom
tandede:fix-required-args-order

Conversation

@tandede

@tandede tandede commented Aug 18, 2026

Copy link
Copy Markdown

Summary

  • preserve each required_args variant's declaration order when listing missing arguments
  • add an exact regression assertion for multi-argument error messages

Why

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 different PYTHONHASHSEED values.

Filtering the declared variant in place makes the message deterministic and keeps it aligned with the method signature.

Validation

  • verified identical output across 8 different PYTHONHASHSEED values
  • python -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

@tandede
tandede marked this pull request as ready for review August 19, 2026 11:28
@tandede
tandede requested a review from a team as a code owner August 19, 2026 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant