[BUG] --resume crashes with "undefined is not an object (evaluating 'd.length')" when session contains api_error entries

Resolved 💬 4 comments Opened Mar 6, 2026 by moksie Closed Mar 6, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

claude --resume <session-id> crashes immediately with:

ERROR undefined is not an object (evaluating 'd.length')

/$bunfs/root/src/entrypoints/cli.js:2631:45754

Stack trace points to WBq — the API error retry renderer component.

Root cause:

The session JSONL file contains api_error system messages where content is missing/null. The error details are stored in the error field instead. During resume, the renderer (WBq / GBq) tries to convert content to a string and call .length on the
result, which is undefined.

Example problematic entry:

```
{
"type": "system",
"subtype": "api_error",
"level": "error",
"content": null,
"error": {
"status": 403,
"error": {
"message": "The security token included in the request is expired"
}
},
"retryAttempt": 1,
"maxRetries": 10,
"retryInMs": 539.9
}


  Note: content is absent (undefined). The renderer at GBq checks typeof O !== "string" and returns null, but WBq separately calls _G_($) on the error object which returns undefined, then evaluates d.length on the result.

 ---                                                                                                                                                                                                                                                      
 ###  Proposed fix:

  The crash is in the GBq / WBq renderer component for api_error system messages during session resume. The code path is:

GBq → checks R.subtype === "api_error" → calls WBq
WBq → extracts R.error → calls _G_(error) to stringify → accesses result.length

  _G_() returns undefined when the error object has the Bedrock structure { status, headers, error: { message } }, causing d.length to crash.

  The fix in the source (likely src/components/messages/SystemMessage.tsx or similar) should be:

  // In the api_error rendering path, add a null guard:
`  const errorString = formatError(message.error) ?? JSON.stringify(message.error) ?? "";
`  // Then errorString.length is safe

  Or more defensively, when reading the session JSONL for resume, skip/handle system messages where content is null:

if (message.subtype === "api_error" && message.content == null) {
// Either skip rendering or derive content from message.error
message.content = message.error?.error?.message
?? JSON.stringify(message.error)
?? "Unknown API error";
}


  ---


### What Should Happen?

The specified session should be resumed without any error.

### Error Messages/Logs

```shell
https://gist.github.com/moksie/375bd1ab85d998fe8d5580e72aa0e57b

Steps to Reproduce

  1. Use Claude Code with Bedrock provider
  2. Let AWS security token expire mid-session (triggers ExpiredTokenException retries)
  3. End the session
  4. claude --resume <session-id> → crash

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.69 / 2.1.70

Platform

AWS Bedrock

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

_No response_

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗