Skip to content

Avoid mutating dicts in jsondumps#1678

Open
RaghunandanKumar wants to merge 1 commit into
openai:mainfrom
RaghunandanKumar:fix-jsondumps-exclude-keys
Open

Avoid mutating dicts in jsondumps#1678
RaghunandanKumar wants to merge 1 commit into
openai:mainfrom
RaghunandanKumar:fix-jsondumps-exclude-keys

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

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