Skip to content

Fix get_json_object dropping object fields that follow an empty key - #24028

Open
vuule wants to merge 6 commits into
NVIDIA:mainfrom
vuule:fix/json-path-empty-object-key
Open

Fix get_json_object dropping object fields that follow an empty key#24028
vuule wants to merge 6 commits into
NVIDIA:mainfrom
vuule:fix/json-path-empty-object-key

Conversation

@vuule

@vuule vuule commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Description

get_json_object used a zero-length name as the signal that no name was present, so the legal JSON key "" was indistinguishable from an absent name and the following colon was left unconsumed, leading to failed parsing of the whole row. For example, $.a on {"":0,"a":1} returned null instead of 1, while {"a":1,"":0} worked.

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

parse_name used a zero-length name as the signal that no name was present,
so the legal JSON key "" was treated as an absent name and the following
colon was left unconsumed. The element-type switch then saw ':' and failed
the whole row, making every field after an empty key unreachable.

Use parse_string's result code to decide whether a name was present, which
distinguishes a present-but-empty name from an absent one.
@copy-pr-bot

copy-pr-bot Bot commented Sep 8, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions github-actions Bot added the libcudf Affects libcudf (C++/CUDA) code. label Sep 8, 2026
@vuule vuule added bug Something isn't working non-breaking Non-breaking change labels Sep 8, 2026
@vuule vuule changed the title Fix get_json_object dropping object fields that follow an empty key Fix get_json_object dropping object fields that follow an empty key Sep 8, 2026
@vuule

vuule commented Sep 8, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test a2330ee

@vuule
vuule marked this pull request as ready for review September 8, 2026 19:20
@vuule
vuule requested a review from a team as a code owner September 8, 2026 19:20
@vuule
vuule requested review from nirandaperera and vyasr September 8, 2026 19:20
@coderabbitai

coderabbitai Bot commented Sep 8, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: a29747d7-a4f3-43bd-a60e-0f85468799d6

📥 Commits

Reviewing files that changed from the base of the PR and between 25b1b5a and a2330ee.

📒 Files selected for processing (2)
  • cpp/src/json/json_path.cu
  • cpp/tests/json/json_tests.cpp

Included review availability: Your plan provides up to 12 included reviews per hour; 10 remain after this review.


📝 Summary

Summary by CodeRabbit

  • Bug Fixes
    • Improved JSON parsing for object names, including empty-string keys.
    • Ensured malformed or incomplete object names are correctly rejected.
    • Preserved JSONPath field selection for objects containing empty-string keys across supported input formats and value types.

Walkthrough

JSONPath name parsing now distinguishes absent names from empty-string keys, propagates parsing failures, and requires a colon after parsed names. Tests cover field selection from objects containing empty-string keys in multiple layouts and value types.

Changes

JSONPath empty-key handling

Layer / File(s) Summary
Name parsing validation
cpp/src/json/json_path.cu
The parser documents empty-string keys and requires whitespace followed by : after every successfully parsed name. It also propagates non-success results from parse_string.
Empty-key regression coverage
cpp/tests/json/json_tests.cpp
ObjectWithEmptyKey verifies selection of the "a" field from objects containing empty-string keys across scalar, object, array, and formatting variants. The SPDX notice includes affiliates.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to a2330

JSONPath parsing now correctly handles empty-string object keys, allowing subsequent fields to be retrieved as expected. The implementation and regression coverage address the stated behavior change with no concrete unresolved current-head risk.

Suggested reviewers: davidwendt

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description directly explains the empty-key parsing defect, its effect on get_json_object, and the test coverage for the fix.
Title check ✅ Passed The title clearly identifies the main change: preventing get_json_object from dropping fields that follow an empty object key.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working libcudf Affects libcudf (C++/CUDA) code. non-breaking Non-breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant