pola-rs/polars · error

failed to read the schema hashes from the file

Error message

failed to read the schema hashes from the file

What it means

`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.

Solutions

  1. Generate the hashes file first: run `dsl-schema update-hashes <path>` (or `make update-dsl-schema-hashes`).
  2. Verify the path is correct and relative paths resolve from your current directory.
  3. Ensure the file is valid UTF-8 text; restore it from git if corrupted.

Example fix

// before
dsl-schema check-hashes ./missing/hashes.json

// after
dsl-schema update-hashes ./hashes.json && dsl-schema check-hashes ./hashes.json
Defensive patterns

Strategy: validation

Validate before calling

import os
path = "./dsl-schema-hashes.json"
if not os.path.isfile(path):
    raise FileNotFoundError(f"run update-hashes first: {path}")
open(path, encoding="utf-8").read()  # also validates UTF-8

Prevention

When it happens

Trigger: `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`.

Common situations: 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.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18). Data as JSON: /api/errors/65955290adf1cc00. Report an issue: GitHub.

Appendix: source

Thrown at crates/polars-plan/src/bin/dsl-schema.rs:95

        let mut file = File::create(path).expect("failed to open the schema file for writing");
        serde_json::to_writer_pretty(&mut file, &schema).expect("failed to serialize the schema");
        writeln!(&mut file).expect("failed to write the last newline");
        file.flush().expect("failed to flush the schema file");
    }

    /// Outputs the current DSL schema hashes into a file at the given path.
    ///
    /// Any existing file at the path is overwritten.
    fn update_hashes(path: impl AsRef<Path>) {
        std::fs::write(path, current_schema_hashes())
            .expect("failed to write the schema into the file");
        eprintln!("the DSL schema file was updated");
    }

    /// Checks that the current schema hashes match the schema hashes in the file.
    fn check_hashes(path: impl AsRef<Path>) {
        let file_hashes =
            std::fs::read_to_string(path).expect("failed to read the schema hashes from the file");
        let expected = current_schema_hashes();
        if file_hashes != expected {
            eprintln!("the schema hashes are not up to date, run `make update-dsl-schema-hashes`");

            eprintln!("expected schema hashes:");
            eprintln!("{}", expected);

            std::process::exit(1);
        }
        eprintln!("the DSL schema hashes are up to date");
    }

    /// Returns the schema hashes as a serialized JSON object.
    /// Each field is named after a data type, with its schema hash as the value.
    fn current_schema_hashes() -> String {
        let schema = DslPlan::dsl_schema();

        let mut hashes = serde_json::Map::new();

View on GitHub (pinned to fe841f959e)