JsonMatch treats matching JSON null values as incorrect

Open Beginner friendly
#1,763 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
python
Domain
testing-qa

Research direction

Start with evals.elsuite.basic.json_match.json_match() and inspect its top-level None check and recursive dictionary comparison. Add regression coverage for top-level, object, and list null matches, plus missing-key versus null mismatches. Done means real JSON null values match while missing keys remain distinct and existing exact matching semantics are unchanged.

Written by the indexing model from the issue text.

Description

Describe the bug

evals.elsuite.basic.json_match.json_match() currently returns False whenever either side is Python None:

if sampled_json is None or correct_json is None:
    return False

That conflates two different cases:

  1. a real JSON null, which json.loads() legitimately decodes to None
  2. a missing dictionary key, which the recursive comparison also currently represents with .get(...) == None

As a result, valid equal JSON containing null is scored incorrectly. For example, {"value": null} does not match the identical ideal answer.

Expected behavior
  • JSON null should match JSON null
  • a missing key should still not match a present key whose value is null
  • existing exact recursive matching semantics should remain unchanged
Proposed fix

Use a private missing-value sentinel when comparing dictionary keys so real None values can be compared normally. Add regression coverage for top-level/null-in-object/null-in-list matches and for missing-key-vs-null mismatches.

Dominant language
Python
Stars
19.5k
Forks
3.1k
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from openai/evals

All issues in openai/evals

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.