claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

Jupyter Notebook File Reading Fails with 400 Bad Request Error

Open rohan-joshi opened this issue 11 months ago • 1 comments

Bug Description running into 400s when asking claude to read from Notebook (jupyter) files

Environment Info

  • Platform: macos
  • Terminal: ghostty
  • Version: 0.2.56
  • Feedback ID: 5997f447-e059-4f8c-8cff-7229aa5b1ed1

Errors

[{"error":"Error: 400 {\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"messages.20.content.0.tool_result.content.1.image.source.base64: invalid base64 data\"}}\n    at H6.generate (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:1054:10176)\n    at $6.makeStatusError (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:1058:7207)\n    at $6.makeRequest (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:1058:8149)\n    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)","timestamp":"2025-03-28T00:38:51.997Z"},{"error":"Error: 400 {\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"messages.20.content.0.tool_result.content.1.image.source.base64: invalid base64 data\"}}\n    at H6.generate (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:1054:10176)\n    at $6.makeStatusError (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:1058:7207)\n    at $6.makeRequest (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:1058:8149)\n    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)","timestamp":"2025-03-28T00:39:23.781Z"},{"error":"Error: 400 {\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"messages.20.content.0.tool_result.content.1.image.source.base64: invalid base64 data\"}}\n    at H6.generate (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:1054:10176)\n    at $6.makeStatusError (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:1058:7207)\n    at $6.makeRequest (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:1058:8149)\n    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)","timestamp":"2025-03-28T00:39:43.534Z"}]

rohan-joshi avatar Mar 28 '25 00:03 rohan-joshi

Related issues:

  • #400
  • #869
  • #930

To reproduce the issue, please see the attached files, which are also summarized below.

The impact of this issue is that the scientific, research, and data science communities extensively use Jupyter (IPython) notebooks with embedded images for interactive development and as self-documenting project workflows.

Enabling Claude Code to seamlessly read and write these Jupyter notebooks would dramatically enhance productivity across these domains.

Thank you so much your work on this impactful tool!

Excerpt from 20250504T093000Z_Claude-Code_Issue-Reproduce-400-Error-From-Ipynb-Base64-Image.ipynb

In [1]:
import matplotlib.pyplot as plt
%matplotlib inline

In [2]:
fig = plt.figure()
ax0 = fig.add_subplot(111)
plt.show(fig)

Excerpt from 20250504T093000Z_Claude-Code_Terminal-Output.txt

$ claude
(...)
> read 20250504T093000Z_Claude-Code_Issue-Reproduce-400-Error-From-Ipynb-Base64-Image.ipynb

⏺ I'll read the Jupyter notebook file for you.

⏺ Read(20250504T093000Z_Claude-Code_Issue-Reproduce-400-Error-From-Ipynb-Base64-Image.ipynb)…
  ⎿  Error: File is a Jupyter Notebook. Use the NotebookRead to read this file.

⏺ I need to use the NotebookRead tool for Jupyter notebook files:

⏺ Read Notebook(20250504T093000Z_Claude-Code_Issue-Reproduce-400-Error-From-Ipynb-Base64-Image.ipynb)…
  ⎿  Read 3 cells
  ⎿  API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.4.content.0.tool_result.content.1.image.source.base64: invalid base64 data"}}

> recover
  ⎿  API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.4.content.0.tool_result.content.1.image.source.base64: invalid base64 data"}}

stharrold avatar May 04 '25 09:05 stharrold

The fix will go out in v1.0.4.

dicksontsai avatar May 25 '25 00:05 dicksontsai

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.

github-actions[bot] avatar Aug 09 '25 14:08 github-actions[bot]