Skip to content

test(parser): pin missing text/thinking field handling (#260) - #263

Open
delexw wants to merge 1 commit into
mainfrom
fix-issue-260
Open

test(parser): pin missing text/thinking field handling (#260)#263
delexw wants to merge 1 commit into
mainfrom
fix-issue-260

Conversation

@delexw

@delexw delexw commented Aug 23, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes #260. Claude Code v2.1.234's release notes confirmed that, on the non-streaming fallback path (typically via third-party gateways), the API response can contain a text content block missing its text field, or a thinking block missing its thinking field — Claude Code itself used to crash on this and now handles it gracefully.

I audited every place in this parser that reads a content block's text or thinking field (classify::extract_assistant_details, sanitize::extract_text, plus session.rs and subagent.rs). All of them already read via serde_json's .get("text"/"thinking").and_then(|v| v.as_str()).unwrap_or("") (or an equivalent if let), which defaults to an empty string when the field is absent. No struct anywhere requires these fields, and no code path panics on a missing one — so the crash scenario described in the issue cannot occur in this codebase today. No production code needed to change.

This PR adds the regression tests the issue explicitly asked for, so the guarantee is now pinned by tests instead of only being an implicit property of the code, and documents it in specs/01-parser-pipeline.md's version-compatibility table.

Changes

Test plan

  • npx vitest run — 498 passed
  • cargo test --manifest-path src-tauri/Cargo.toml — 691 passed (including the 4 new tests)
  • cargo clippy --manifest-path src-tauri/Cargo.toml -- -D warnings — clean
  • cargo fmt --manifest-path src-tauri/Cargo.toml -- --check — clean
  • npx oxlint / npx oxfmt / npx tsc --noEmit — clean

Claude Code v2.1.234 confirmed that on the non-streaming fallback path
(typically via third-party gateways), a text content block can arrive
without its text field, or a thinking block without its thinking field.

Every call site that reads these fields (classify::extract_assistant_details,
sanitize::extract_text, session.rs, subagent.rs) already falls back to an
empty string via serde_json's get().and_then(as_str()).unwrap_or("")
pattern, so no panic is possible today. Add the regression tests the issue
requested to pin this guarantee, and document it in the parser pipeline spec.

Fixes #260
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.

[Compat] Claude Code v2.1.234: text/thinking content blocks confirmed to sometimes miss their core field via gateways

1 participant