Fix JSON parsing robustness in batchexecute #8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes critical JSON parsing errors in the
batchexecutepackage that were causing thenlm listcommand to fail with type assertion errors.Problem
The original code assumed all API responses would be in
[][]interface{}format, but Google's NotebookLM API sometimes returns responses with mixed data types (including numbers), causing this error:This issue particularly manifests when:
Root Cause Analysis
[][]interface{}fails when response contains non-array elementsSolution
interface{}for initial unmarshaling with proper type assertionTechnical Changes
1.
decodeResponse()Function2.
decodeChunkedResponse()Functionjson.Decoder.InputOffset()to find complete object boundaries3. Data Processing
Testing
✅ Fixed original error:
nlm listnow works with mixed-type responses✅ Unicode support: Properly handles Japanese/Chinese notebook titles
✅ Chunked responses: Handles truncated JSON chunks gracefully
✅ Performance: Eliminates unnecessary JSON re-encoding overhead
✅ Clean output: No debug noise in normal operation
Backward Compatibility
This change maintains full backward compatibility while making the JSON parsing significantly more robust against various response formats from the NotebookLM API.
Impact
This fix resolves a blocking issue preventing users from listing their notebooks when responses contain mixed data types or Unicode characters, which is common in international usage scenarios.
🤖 Generated with Claude Code