Skip to content

Avoid mutating dicts in jsondumps#1677

Closed
RaghunandanKumar wants to merge 1 commit into
openai:mainfrom
RaghunandanKumar:codex/jsondumps-exclude-keys-copy
Closed

Avoid mutating dicts in jsondumps#1677
RaghunandanKumar wants to merge 1 commit into
openai:mainfrom
RaghunandanKumar:codex/jsondumps-exclude-keys-copy

Conversation

@RaghunandanKumar

Copy link
Copy Markdown

Summary

  • avoid mutating caller-owned dictionaries when jsondumps(..., exclude_keys=...) is used
  • ignore excluded keys that are not present, matching filtering behavior instead of raising KeyError
  • add a focused regression test for both cases

Why

jsondumps previously deleted excluded keys directly from dictionary inputs before encoding. That produced surprising side effects for callers that reused the same object after serialization, and it also raised when an excluded key was absent.

Verification

  • OPENAI_API_KEY=dummy uv run --python 3.11 pytest evals/data_test.py evals/record_test.py tests/unit/evals/test_metrics.py

@RaghunandanKumar RaghunandanKumar marked this pull request as ready for review June 10, 2026 02:58
@RaghunandanKumar

Copy link
Copy Markdown
Author

Replaced by #1678 with a cleaner branch name.

@RaghunandanKumar RaghunandanKumar deleted the codex/jsondumps-exclude-keys-copy branch June 10, 2026 03:01
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