{"record":{"id":"65955290adf1cc00","repo":"pola-rs/polars","slug":"failed-to-read-the-schema-hashes-from-the-file","errorCode":null,"errorMessage":"failed to read the schema hashes from the file","messagePattern":"failed to read the schema hashes from the file","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-plan/src/bin/dsl-schema.rs","lineNumber":95,"sourceCode":"        let mut file = File::create(path).expect(\"failed to open the schema file for writing\");\n        serde_json::to_writer_pretty(&mut file, &schema).expect(\"failed to serialize the schema\");\n        writeln!(&mut file).expect(\"failed to write the last newline\");\n        file.flush().expect(\"failed to flush the schema file\");\n    }\n\n    /// Outputs the current DSL schema hashes into a file at the given path.\n    ///\n    /// Any existing file at the path is overwritten.\n    fn update_hashes(path: impl AsRef<Path>) {\n        std::fs::write(path, current_schema_hashes())\n            .expect(\"failed to write the schema into the file\");\n        eprintln!(\"the DSL schema file was updated\");\n    }\n\n    /// Checks that the current schema hashes match the schema hashes in the file.\n    fn check_hashes(path: impl AsRef<Path>) {\n        let file_hashes =\n            std::fs::read_to_string(path).expect(\"failed to read the schema hashes from the file\");\n        let expected = current_schema_hashes();\n        if file_hashes != expected {\n            eprintln!(\"the schema hashes are not up to date, run `make update-dsl-schema-hashes`\");\n\n            eprintln!(\"expected schema hashes:\");\n            eprintln!(\"{}\", expected);\n\n            std::process::exit(1);\n        }\n        eprintln!(\"the DSL schema hashes are up to date\");\n    }\n\n    /// Returns the schema hashes as a serialized JSON object.\n    /// Each field is named after a data type, with its schema hash as the value.\n    fn current_schema_hashes() -> String {\n        let schema = DslPlan::dsl_schema();\n\n        let mut hashes = serde_json::Map::new();","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/crates/polars-plan/src/bin/dsl-schema.rs#L77-L113","documentation":"`check_hashes` reads the stored hashes file with `std::fs::read_to_string(path)` and expects success. If the file is missing, unreadable, or not valid UTF-8, the process panics with this message. This runs before comparing hashes, so a missing file aborts the check.","triggerScenarios":"`dsl-schema check-hashes <path>` where the hashes file doesn't exist, was deleted, lives outside the working directory, or contains invalid UTF-8; also when the file was never generated via `update-hashes`.","commonSituations":"Fresh clone where hashes weren't checked in or were gitignored; running the check from a different working directory with a relative path; file corrupted or replaced with binary content.","solutions":["Generate the hashes file first: run `dsl-schema update-hashes <path>` (or `make update-dsl-schema-hashes`).","Verify the path is correct and relative paths resolve from your current directory.","Ensure the file is valid UTF-8 text; restore it from git if corrupted."],"exampleFix":"// before\ndsl-schema check-hashes ./missing/hashes.json\n\n// after\ndsl-schema update-hashes ./hashes.json && dsl-schema check-hashes ./hashes.json","handlingStrategy":"validation","validationCode":"import os\npath = \"./dsl-schema-hashes.json\"\nif not os.path.isfile(path):\n    raise FileNotFoundError(f\"run update-hashes first: {path}\")\nopen(path, encoding=\"utf-8\").read()  # also validates UTF-8","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run update-hashes before the first check-hashes in a fresh environment.","Don't gitignore the hashes file if CI runs check-hashes.","Use absolute paths or run from the repo root so relative paths resolve."],"tags":["io","file-read","panic"],"backgroundTag":"file-not-found","analyzedSha":"fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e","analyzedAt":"2026-09-18T22:14:11.667Z","contentChangedAt":"2026-09-18T22:14:11.667Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}