{"record":{"id":"c6761ce8dd730eb6","repo":"can1357/oh-my-pi","slug":"failed-to-read-filter-definition-e","errorCode":null,"errorMessage":"failed to read filter definition {}: {e}","messagePattern":"failed to read filter definition (.+?): (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/pi-natives/build.rs","lineNumber":58,"sourceCode":"\t\tprintln!(\"cargo:rerun-if-changed={}\", path.display());\n\t\tmatch fs::read_to_string(&path) {\n\t\t\tOk(body) => {\n\t\t\t\tlet filename = path\n\t\t\t\t\t.file_name()\n\t\t\t\t\t.and_then(|n| n.to_str())\n\t\t\t\t\t.unwrap_or(\"unknown\");\n\t\t\t\twriteln!(concatenated, \"# --- {filename} ---\").expect(\"write to String\");\n\t\t\t\tfor line in body.lines() {\n\t\t\t\t\tlet trimmed = line.trim_start();\n\t\t\t\t\tif trimmed.starts_with(\"schema_version\") {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tconcatenated.push_str(line);\n\t\t\t\t\tconcatenated.push('\\n');\n\t\t\t\t}\n\t\t\t\tconcatenated.push('\\n');\n\t\t\t},\n\t\t\tErr(e) => panic!(\"failed to read filter definition {}: {e}\", path.display()),\n\t\t}\n\t}\n\n\tfs::write(&output_path, concatenated)\n\t\t.unwrap_or_else(|e| panic!(\"failed to write {}: {e}\", output_path.display()));\n}\n","sourceCodeStart":40,"sourceCodeEnd":65,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/crates/pi-natives/build.rs#L40-L65","documentation":"pi-natives' build script generates crates/pi-natives/out/.../builtin_filters.toml at compile time by concatenating every *.toml filter definition in src/shell/minimizer/defs/. If any definition file exists in the directory listing but cannot be read to a String (permissions, decode error, vanished mid-build), the build script panics with this message, failing the cargo build with the offending path and io/UTF-8 error embedded.","triggerScenarios":"Running `cargo build`/`cargo test` for pi-natives when a .toml file inside src/shell/minimizer/defs/ cannot be read: unreadable file permissions, invalid UTF-8 content, or the file being deleted/replaced between fs::read_dir and fs::read_to_string.","commonSituations":"Cloning the repo on a filesystem that mangles permissions; an editor or tool leaving a temp/lock .toml with restrictive mode in defs/; a non-UTF-8 (binary or Latin-1) file dropped into defs/; running the build as a different user than the file owner; read-only mounts or container volume permission mismatches.","solutions":["Read the full panic message to identify the offending path, then check its permissions (`ls -l src/shell/minimizer/defs/`) and fix with chmod/chown so the build user can read it.","Verify the file is valid UTF-8 (`file` / `iconv -f utf-8 -t utf-8 <path>`); re-save or delete any binary or wrong-encoding .toml in defs/.","Remove stale temp/backup files (e.g. *.toml~, editor swap files) from the defs directory and rebuild.","Do a clean checkout or `git checkout -- crates/pi-natives/src/shell/minimizer/defs/` if the files were locally modified or corrupted."],"exampleFix":"// before: unreadable definition blocks the build\n$ ls -l crates/pi-natives/src/shell/minimizer/defs/\n-rw------- 1 root root 240 builtin-rm.toml\n// panic: failed to read filter definition .../builtin-rm.toml: Permission denied (os error 13)\n\n// after: restore readability, then rebuild\n$ sudo chmod 644 crates/pi-natives/src/shell/minimizer/defs/builtin-rm.toml\n$ cargo build -p pi-natives","handlingStrategy":"validation","validationCode":"# Run before building to catch unreadable/binary filter defs:\nfor f in crates/pi-natives/src/shell/minimizer/defs/*.toml; do\n  test -r \"$f\" || { echo \"unreadable: $f\"; exit 1; }\n  iconv -f utf-8 -t utf-8 \"$f\" >/dev/null || { echo \"not utf-8: $f\"; exit 1; }\ndone","typeGuard":null,"tryCatchPattern":"# Build script panics abort the build; capture and triage:\nif ! cargo build -p pi-natives 2>build.log; then\n  grep -q 'failed to read filter definition' build.log && \\\n    echo \"Fix/restore the listed file in src/shell/minimizer/defs/\"\n  exit 1\nfi","preventionTips":["Keep only plain UTF-8 .toml files in src/shell/minimizer/defs/; never drop editor temp or lock files there.","Verify file permissions after cloning on unusual filesystems or in containers.","Run `git status` on the defs directory before building to catch locally corrupted definitions."],"tags":["build-script","filesystem","permissions","compile-time"],"backgroundTag":"build-script-io-failure","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}