Skip to content

[bug] File reads load entire files before truncating and report partial data as complete #248

Closed

Description

@AetherAI3

Problem

readFile calls readFileSync(abs, "utf8") before slicing to MAX_OUTPUT. It can synchronously load an arbitrarily large workspace file, block the console, and return only a prefix with exit code 0 and no truncation marker. Unlike snapshot, it does not check size or reject binary content.

Fix / acceptance

  • Read a bounded byte/line range from the file instead of loading the whole file. Return path, returned range, total size where known, and an explicit truncation/continuation indication.
  • Reject or clearly identify binary/unsupported content. Preserve valid UTF-8 at range boundaries and existing workspace path checks.
  • Add optional range arguments through the canonical registry/protocol and relevant local/hosted consumers; keep existing callers compatible through a bounded default.
  • Test a large/sparse file, final-line continuation, empty file, binary file, multibyte boundaries and read errors. Memory must scale with the requested bound, not file size, and partial content must never masquerade as a complete file.

Priority: P1. This prevents partial reads from feeding unsafe whole-file replacements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions