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
std.fs.read_file silently returns "" for a missing/unreadable path — errors indistinguishable from an empty file #909
use std.fs
use std.builtins.print_i64
fn main:
let text = read_file("/definitely/not/a/real/path.txt")
print_i64(text.len()) // prints 0, rc=0 — no error anywhere
Why it bit
During the #795 directive sweep, a shell quoting slip passed one
newline-joined mega-argument as the file path. read_file returned ""
for the bogus path, the migration script matched nothing, and the only
symptom was "migrated 0 files" — the failure was completely silent. A
missing input file and an empty input file are indistinguishable.
This is the repo's own "no silent fallbacks" doctrine violated at the
stdlib surface: the API swallows the error class users most need to see
(typo'd path, permissions, TOCTOU deletion).
Expected
Either read_file(path: &str) -> Result[str, FsError] (callers use ?
— the with-y shape), or at minimum a loud panic on missing paths with a
separate read_file_opt/exists for probe-style callers. Signature
change touches all current callers (tools/, build/, tests) — small
sweep, mechanical.
Same review should cover write_file's error surface (returns i32 rc —
at least visible, but unchecked at most call sites).
Activity
CLAUDE.md: tools use std.fs, never the with_fs_* extern seam (#901)
std.fs: read_file returns Result[str, IoError]; ToolFs.read_text pani…