You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
read_file with offset beyond EOF reports "Note: File is empty" for non-empty files #1728
read_file with an offset beyond the end of a non-empty file returns "Note: File is empty" instead of an error. The model is told the file is empty and may regenerate/overwrite content from memory, destroying user data.
Mechanism
readWithSlice (src/integrations/misc/indentation-reader.ts:444-452) returns the error string Error: offset N is beyond file end (M lines) with returnedLines: 0, wasTruncated: false. In ReadFileTool.processTextFile (src/core/tools/ReadFileTool.ts:325-327), the else if (result.returnedLines === 0) branch discards that string and substitutes "Note: File is empty".
That branch is also dead code for its intended purpose: a genuinely empty file parses to one blank line ("".split("\n") === [""] → returnedLines: 1), so the branch can only ever fire for the out-of-range error.
Repro
Create a 5-line file, let the model read it (so it has a stale line count).
Shorten the file externally (or via edit), then the model calls read_file with offset: 100.
Result: "Note: File is empty" — for a file with content.
Suggested fix
Gate the empty note on an actually-empty file: else if (result.returnedLines === 0 && result.totalLines === 0), letting the real beyond-EOF error propagate.
Activity