Skip to content

[fix](json) avoid json_set crash on invalid jsonb value#64088

Open
mrhhsg wants to merge 1 commit into
apache:branch-3.1from
mrhhsg:fix/json-set-invalid-jsonb-value-3.1
Open

[fix](json) avoid json_set crash on invalid jsonb value#64088
mrhhsg wants to merge 1 commit into
apache:branch-3.1from
mrhhsg:fix/json-set-invalid-jsonb-value-3.1

Conversation

@mrhhsg
Copy link
Copy Markdown
Member

@mrhhsg mrhhsg commented Jun 3, 2026

What problem does this PR solve?

Issue Number: None

Problem Summary: json_set may receive an invalid JSONB payload from a nullable expression and crash when converting it to rapidjson. This patch treats invalid JSONB payloads as JSON null in the json modify value path and uses the correct row index for nullable constant value columns.

Release note

None

Check List (For Author)

  • Test:
    • Build: doris-local-regression --network 10.26.20.3/24 --offset 42300 build
    • Regression test: doris-local-regression --network 10.26.20.3/24 --offset 42300 run -d nereids_p0/sql_functions/json_function -s test_query_json_set_jsonb_nullable_value
    • git diff --check
  • Behavior changed: No
  • Does this need documentation: No

### What problem does this PR solve?

Issue Number: None

Problem Summary: json_set may receive an invalid JSONB payload from a nullable expression and crash when converting it to rapidjson.

### Release note

None

### Check List (For Author)

- Test:

    - Regression test: doris-local-regression --network 10.26.20.3/24 --offset 42300 run -d nereids_p0/sql_functions/json_function -s test_query_json_set_jsonb_nullable_value

    - Build: doris-local-regression --network 10.26.20.3/24 --offset 42300 build

- Behavior changed: No

- Does this need documentation: No
@mrhhsg
Copy link
Copy Markdown
Member Author

mrhhsg commented Jun 3, 2026

/review

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review opinion: the PR looks safe to proceed. I did not find any critical blocking issues in the changed backend logic or regression test.

Critical checkpoints:

  • Correctness: The nullable constant index fix uses the same indexed row for both the value column and its null map, which addresses the likely out-of-bounds/crash path. The JSONB null fallback also prevents dereferencing a null JsonbValue.
  • Scope/regression risk: The JSONB parser fallback is global to the JSON function value parser, but it maps unparsable JSONB payloads to JSON null rather than crashing; I did not find a concrete incompatible behavior regression in this PR context.
  • Tests: The new regression covers nullable JSONB values and the invalid JSONB crash scenario with enough rows to exercise vectorized row/null-map handling. git diff --check passed locally.
  • Documentation/compatibility: No user-facing syntax or documented behavior change found that requires docs.
  • User focus: No additional user-provided review focus was present.

@mrhhsg
Copy link
Copy Markdown
Member Author

mrhhsg commented Jun 3, 2026

run buildall

@mrhhsg mrhhsg marked this pull request as ready for review June 4, 2026 01:42
@mrhhsg mrhhsg requested a review from morrySnow as a code owner June 4, 2026 01:42
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