Skip to content

Conversation

@f14XuanLv
Copy link
Contributor

@f14XuanLv f14XuanLv commented Nov 12, 2025

fix: upgrade isbinaryfile from 5.0.4 to 5.0.7

  • Updates constraint from ^5.0.2 to ^5.0.7
  • Fixes "invalid array length" crash with UTF-8 files that should be recognized as text

Upstream package fix: gjtorikian/isBinaryFile#91

Related GitHub Issue

Closes: #8109
Resolves: #6242 (duplicate)

Roo Code Task Context (Optional)

N/A

Description

This PR upgrades the isbinaryfile dependency to fix a critical bug that affects Roo-Code's ability to process files containing multibyte UTF-8 characters (Chinese, Japanese, Korean, emoji, etc.).

Problem:

When processing files with non-ASCII characters (as reported in #8109 and #6242), Roo-Code encountered a "RangeError: Invalid array length" error due to a bug in [email protected]. This bug occurs when UTF-8 multibyte sequences are split across the 512-byte buffer boundary used for file type detection.

Error Stack Trace (from both #6242 and my reproduction):

RangeError: Invalid array length
    at [email protected]/lib/index.js:36:16
    at readProtoMessage ([email protected]/lib/index.js:68:20)
    at isBinaryProto ([email protected]/lib/index.js:82:14)
    at isBinaryCheck ([email protected]/lib/index.js:228:32)

Root Cause:

Solution:

I authored the upstream fix (gjtorikian/isBinaryFile#91) which properly handles UTF-8 multibyte sequences at buffer boundaries by:

  • Extending the read buffer to 515 bytes for validation
  • Maintaining the original 512-byte scanning logic
  • Ensuring complete UTF-8 sequences can be validated

This PR updates the dependency constraint from ^5.0.2 to ^5.0.7 to ensure all installations receive the fix.

Changes:

# src/package.json
{
  "dependencies": {
-   "isbinaryfile": "^5.0.2",
+   "isbinaryfile": "^5.0.7"
  }
}
# pnpm-lock.yaml
  isbinaryfile:
-   specifier: ^5.0.2
-   version: 5.0.4
+   specifier: ^5.0.7
+   version: 5.0.7

Note: The previous constraint ^5.0.2 allowed installation of buggy version 5.0.4. The new constraint ^5.0.7 ensures the fixed version is always used.

Test Procedure

Manual Testing:

  1. Download the problematic test file: utf8-boundary-truncation_case.py
  2. Place it in a local directory
  3. Trigger Roo-Code AI analysis on this file
  4. Verify no "invalid array length" error occurs
  5. Verify the file is correctly recognized as a Python text file (not binary)
  6. Verify AI agents can successfully read and analyze the file

Expected Results:

  • ✅ No crash or error messages
  • ✅ File correctly identified as text
  • ✅ Roo-Code AI can process the file normally

Pre-Submission Checklist

Screenshots / Videos

Before ([email protected]) - Error State:

Before: Invalid array length error

Error shown: "未捕获的错误(2)" - "invalid array length" when processing UTF-8 file with Chinese comments. Roo-Code fails to analyze the file.

After ([email protected]) - Fixed:

After: No error, file processed successfully

Success: "任务完成" - File is successfully recognized as text and processed by Roo-Code AI agents. Note the green "No Error This Time!" indicator in the console.

Documentation Updates

  • No documentation updates are required.

This is a dependency bug fix with no user-facing feature changes.

Additional Notes

Related Issues:

This PR fixes the root cause of two reported issues:

Both issues report the same problem: Roo-Code extension freezes when processing files containing Chinese characters (or other multibyte UTF-8 sequences) at specific buffer boundary positions.

Reproduced and Verified:

I've personally reproduced the exact same error stack trace reported in #6242:

RangeError: Invalid array length
    at [email protected]/lib/index.js:36:16

The error occurs at the exact same code location when processing files containing UTF-8 multibyte sequences (Chinese characters) at byte positions 510-512.

Test File Used:

  • utf8-boundary-truncation_case.py
  • Contains Chinese comments at the critical buffer boundary position
  • This file is now part of the upstream test suite to prevent regression

Verification:

Impact on Roo-Code Users:

This fix is particularly important for:

  • International developers using Chinese, Japanese, Korean, or other multibyte characters in code comments
  • Teams working on projects with diverse language documentation
  • Anyone encountering "invalid array length" errors when using Roo-Code with non-ASCII files

Upstream Package Contribution:

I'm the author of the upstream fix:

Get in Touch

GitHub: @f14XuanLv
Discord: f14xuanlv


Important

Upgrade isbinaryfile to ^5.0.7 to fix UTF-8 file processing crash and ensure correct text file detection.

This description was created by Ellipsis for 001c1c6. You can customize this summary. It will automatically update as commits are pushed.

- Updates constraint from ^5.0.2 to ^5.0.7
- Fixes 'invalid array length' crash with UTF-8 files that should be recognized as text

Upstream library fix: gjtorikian/isBinaryFile#91
@f14XuanLv f14XuanLv requested review from cte, jr and mrubens as code owners November 12, 2025 07:18
@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. bug Something isn't working labels Nov 12, 2025
@roomote
Copy link
Contributor

roomote bot commented Nov 12, 2025

Rooviewer Clock   See task on Roo Cloud

Review completed - no issues found.

This is a clean dependency upgrade that fixes a critical UTF-8 file processing crash. The changes are minimal (updating isbinaryfile from ^5.0.2 to ^5.0.7) and well-justified by the upstream fix authored by the PR creator.

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Nov 12, 2025
@hannesrudolph hannesrudolph moved this from Triage to PR [Needs Prelim Review] in Roo Code Roadmap Nov 12, 2025
@hannesrudolph hannesrudolph added PR - Needs Preliminary Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Nov 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working PR - Needs Preliminary Review size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

Status: PR [Needs Prelim Review]

2 participants