Reject extra fields in Extended JSON timestamps

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Fixed
    • Priority: Unknown
    • 4.18.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?
    • None
    • None
    • None
    • None
    • None
    • None

      winklemad has created PR #2961: PYTHON-XXXX Reject extra fields in Extended JSON timestamps in mongo-python-driver

      Issue Text:
      PYTHON-XXXX

        1. Changes in this PR

      `bson.json_util.loads` now rejects `$timestamp` value documents that contain anything other than the required `t` and `i` components. Previously, unexpected fields could be silently discarded while constructing `bson.timestamp.Timestamp`.

      This adds regressions for both additional fields and same-length invalid key sets, and updates the changelog and contributor list.

      AI assistance disclosure: I used OpenAI Codex to help investigate the existing behavior, search for duplicates, implement the change, and run validation. I reviewed and understand every changed line and can explain and maintain the contribution.

        1. Test Plan
      • `python3 -m unittest test.test_json_util.TestJsonUtil.test_timestamp test.test_json_util.TestJsonUtil.test_timestamp_with_invalid_fields`
      • `python3 -m unittest test.test_json_util test.test_bson_corpus`
      • `ruff check bson/json_util.py test/test_json_util.py`
      • `ruff format --check bson/json_util.py test/test_json_util.py`
      • `python3 -m compileall -q bson/json_util.py test/test_json_util.py`
      • `git diff --check`

      All listed checks passed.

        1. Checklist
          1. Checklist for Author
      • [x] Did you update the changelog (if necessary)?
      • [x] Is there test coverage?
      • [ ] Is any followup work tracked in a JIRA ticket? If so, add links.

      No follow-up work is currently identified. As an external contributor without an existing JIRA ticket, I retained the template `PYTHON-XXXX` placeholder for a MongoDB employee to update.

          1. Checklist for Reviewer
      • [ ] Does the title of the PR reference a JIRA Ticket?
      • [ ] Do you fully understand the implementation?
      • [ ] Is all relevant documentation updated?

            Assignee:
            Steve Silvester
            Reporter:
            TPM Jira Automations Bot
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: