[BUG] RangeError: Invalid string length

Resolved 💬 3 comments Opened Aug 13, 2025 by Rokurolize Closed Aug 17, 2025

Environment

  • Platform (select one):
  • [x] Anthropic API
  • [ ] AWS Bedrock
  • [ ] Google Vertex AI
  • [ ] Other: <!-- specify -->
  • Claude CLI version: 1.0.77 (Claude Code) <!-- output of claude --version -->
  • Operating System: WSL2 Ubuntu 22.04 <!-- e.g. macOS 14.3, Windows 11, Ubuntu 22.04 -->
  • Terminal: Bash <!-- e.g. iTerm2, Terminal App -->

Bug Description

Claude Code has crashed.

<!-- A clear and concise description of the bug -->

Steps to Reproduce

  1. <!-- First step -->
  2. <!-- Second step -->
  3. <!-- And so on... -->

Expected Behavior

<!-- What you expected to happen -->

Actual Behavior

<!-- What actually happened -->

Additional Context

<!-- Add any other context about the problem here, such as screenshots, logs, etc. -->


● I can see the parser is working (the streaming JSON parsing with ijson is successful), but
  there are validation errors because the data models are too strict. The real-world OpenAI
  export data contains:

  1. "tool" role - not just "user", "assistant", "system"
  2. Complex content parts - not just strings, but objects with image metadata

  This is exactly the kind of real-world issue that Linus identified would happen. Let me proceed
   to Phase 3 and have Linus review this.

  Update Todos
  ⎿  ☒ Phase 1: Design approval with Linus agent  
     ☒ Phase 2: Implementation with safeguards
     ☐ Phase 3: Post-verification with Linus agent

● Phase 3: Post-Verification Loop

  linus-code-reviewer(Final verification review)
  ⎿  "role": "assistant"         
     "role": "system"
     "role": "tool"
     … +1 line (ctrl+r to expand)
     Bash(bash -c 'head -100 temp_extract/conversations.json | grep -A 5 "\"parts\": \\[" | head -20')
     Waiting…
     +15 more tool uses

✢ Puzzling… (1134s · ⚒ 11.0k tokens · esc to interrupt)

╭───────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ >                                                                                                         │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────╯
  ubuntu@roku-pc:~/workbench/projects/openai-analyzer
  ⏵⏵ bypass permissions on (shift+tab to cycle)
file:///home/ubuntu/.nvm/versions/node/v22.18.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1356
`);if(D!==-1){if(Z=A.substring(0,D),Z.length+1>B)return`${Z.substring(0,B-1)}…`;return`${Z}…`}}if(Z.length<=B)return Z;return`${Z.substring(0,B-1)}…`}function cm(A){if(A<60000){let D=(A/1000).toFixed(1);return`${D.endsWith(".0")?D.slice(0,-2):D}s`}let B=Math.floor(A/3600000),Q=Math.floor(A%3600000/60000),Z=(A%60000/1000).toFixed(1);if(B>0)return`${B}h ${Q}m ${Z}s`;if(Q>0)return`${Q}m ${Z}s`;return`${Z}s`}function SI(A){let B=A>=1000;return new Intl.NumberFormat("en",{notation:"compact",minimumFractionDigits:B?1:0,maximumFractionDigits:1}).format(A).toLowerCase()}function ex1(A,B={}){let{style:Q="narrow",numeric:Z="always",now:D=new Date}=B,G=A.getTime()-D.getTime(),F=Math.trunc(G/1000),I=[{unit:"year",seconds:31536000,shortUnit:"y"},{unit:"month",seconds:2592000,shortUnit:"mo"},{unit:"week",seconds:604800,shortUnit:"w"},{unit:"day",seconds:86400,shortUnit:"d"},{unit:"hour",seconds:3600,shortUnit:"h"},{unit:"minute",seconds:60,shortUnit:"m"},{unit:"second",seconds:1,shortUnit:"s"}];for(let{unit:W,seconds:J,shortUnit:X}of I)if(Math.abs(F)>=J){let V=Math.trunc(F/J);if(Q==="narrow"&&J<86400)return F<0?`${Math.abs(V)}${X} ago`:`in ${V}${X}`;return new Intl.RelativeTimeFormat("en",{style:"long",numeric:Z}).format(V,W)}if(Q==="narrow")return F<=0?"0s ago":"in 0s";return new Intl.RelativeTimeFormat("en",{style:Q,numeric:Z}).format(0,"second")}function Bv1(A,B={}){let{now:Q=new Date,...Z}=B;if(A>Q)return ex1(A,{...Z,now:Q});return ex1(A,{...Z,numeric:"always",now:Q})}function S11(A,B=!1){if(!A)return;let Q=new Date(A*1000),Z=Q.getMinutes(),D=Q.toLocaleTimeString("en-US",{hour:"numeric",minute:Z===0?void 0:"2-digit",hour12:!0}),G=Intl.DateTimeFormat().resolvedOptions().timeZone;return D.replace(/ ([AP]M)/i,(F,I)=>I.toLowerCase())+(B?` (${G})`:"")}var qLB=F1(ELB(),1);class eD1{capacity;buffer;head=0;size=0;constructor(A){this.capacity=A;this.buffer=new Array(A)}add(A){if(this.buffer[this.head]=A,this.head=(this.head+1)%this.capacity,this.size<this.capacity)this.size++}addAll(A){for(let B of A)this.add(B)}getRecent(A){let B=[],Q=this.size<this.capacity?0:this.head,Z=Math.min(A,this.size);for(let D=0;D<Z;D++){let G=(Q+this.size-Z+D)%this.capacity;B.push(this.buffer[G])}return B}toArray(){if(this.size===0)return[];let A=[],B=this.size<this.capacity?0:this.head;for(let Q=0;Q<this.size;Q++){let Z=(B+Q)%this.capacity;A.push(this.buffer[Z])}return A}clear(){this.head=0,this.size=0}length(){return this.size}}var ULB=137,wLB=143;function $LB(A){let B=null,Q="";A.on("data",(D)=>{if(B)B.write(D);else Q+=D});let Z=()=>Q;return{get:Z,asStream(){return B=new fQ8({highWaterMark:10485760}),B.write(Z()),Q="",B}}}function NLB(A,B,Q,Z){let D="running",G,F=$LB(A.stdout),I=$LB(A.stderr);if(Z){let V=new eD1(10),K=0,C=(H)=>{let $=H.toString().split(`
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            

RangeError: Invalid string length
    at Socket.<anonymous> (file:///home/ubuntu/.nvm/versions/node/v22.18.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1356:2528)
    at Socket.emit (node:events:530:35)
    at Socket.emit (node:domain:489:12)
    at addChunk (node:internal/streams/readable:561:12)
    at readableAddChunkPushByteMode (node:internal/streams/readable:512:3)
    at Readable.push (node:internal/streams/readable:392:5)
    at Pipe.onStreamRead (node:internal/stream_base_commons:189:23)

Node.js v22.18.0
ubuntu@roku-pc:~/workbench/projects/openai-analyzer$ claude --version
1.0.77 (Claude Code)
ubuntu@roku-pc:~/workbench/projects/openai-analyzer$ 

View original on GitHub ↗

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