Skip to content

fix: parse the LLM query array as JSON instead of splitting on commas - #134

Merged
sahenjp merged 1 commit into
sahenjp:mainfrom
souta-lab:fix/a14-json-array-parsing
Nov 11, 2026
Merged

sahenjp merged 1 commit into
sahenjp:mainfrom
souta-lab:fix/a14-json-array-parsing

Conversation

@souta-lab

Copy link
Copy Markdown
Contributor

Summary

Parse the planned-query array in the deep research endpoint with serde_json instead of splitting the array body on commas, as prescribed by A14 in docs/AUDIT-2026-11-02.md.

Root cause

parse_string_array in src/deep_research.rs extracted the text between the brackets and split it on ,, then trimmed quote characters from each fragment. Any valid JSON string entry containing a comma (for example "Paris, Texas population") was split into fragments, and escaped quotes inside entries were mangled.

Changes

  • The slice between the outermost brackets is extracted as before (this also strips surrounding prose and markdown fences) and is now parsed with serde_json::from_str::<Vec<String>>.
  • A reply whose bracketed slice is not a valid JSON string array now falls back to the question-derived queries instead of returning comma-split fragments.
  • Three regression tests: entries containing commas, escaped quotes (the audit's example), and the invalid-JSON fallback.

No dependencies, configuration, or response fields change; serde_json is already a dependency.

Verification

Linux x86_64, Rust 1.99.1:

  • cargo test --all-targets deep_research: 8 passed (5 existing + 3 new).
  • cargo test --all-targets: 1110 passed, 1 failed. The failure is tests/pdf_pages.rs (Japanese PDF text extraction), which needs Poppler Japanese CMap data that is not installed in this sandbox; it fails identically on unmodified main and is unrelated to this change. Proxy environment variables were excluded from the test process for the loopback fixtures, as in fix: reject executable schemes in search results #52.
  • cargo fmt --all --check: passed.
  • cargo clippy --all-targets -- -D warnings: passed.

Limitations

Other platforms are left to CI.

Related

Addresses A14 in the existing audit.

AI assistance: implementation and regression tests.

@souta-lab
souta-lab requested a review from sahenjp as a code owner November 9, 2026 23:24
@sahenjp
sahenjp merged commit fee1a93 into sahenjp:main Nov 11, 2026
27 of 28 checks passed
sahenjp pushed a commit that referenced this pull request Nov 11, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.31.2](v0.31.1...v0.31.2)
(2026-11-11)


### Bug Fixes

* parse the LLM query array as JSON instead of splitting on commas
([#134](#134))
([fee1a93](fee1a93))
* update rustix to 1.1.6 for RUSTSEC-2026-0486
([c07945e](c07945e))
* validate timeout_limit at the HTTP entry point instead of panicking on
inf ([#135](#135))
([f318d72](f318d72))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

2 participants