nikivdev/code · error

prek pre-push validation failed

Error message

prek pre-push validation failed

What it means

`run_prek_validation` executes the `prek` binary as part of the pre-push hook and bails when the child process exits non-zero. This means prek itself ran but its checks (lint/format/hooks it manages) failed, so the push validation is treated as failed.

Source

Thrown at src/push_hook.rs:392

        cmd.env("FLOW_PUSH_CURRENT_BRANCH", branch);
    }
    if let Some(branch) = home_branch
        && !branch.trim().is_empty()
    {
        cmd.env("FLOW_PUSH_HOME_BRANCH", branch);
    }

    let status = cmd.status().with_context(|| {
        format!(
            "failed to run prek pre-push validation via {}",
            prek_bin.display()
        )
    })?;
    if status.success() {
        return Ok(());
    }

    bail!("prek pre-push validation failed")
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn rendered_hook_script_mentions_internal_eval_command() {
        let script = render_pre_push_hook_script();
        assert!(script.contains("push hook-eval"));
        assert!(script.contains(FLOW_PRE_PUSH_HOOK_MARKER));
        assert!(script.contains("legacy_hook"));
        assert!(script.contains("same_path"));
    }
}

View on GitHub (pinned to a747e741ae)

Solutions

  1. Run `prek` (or `prek run --all-files`) locally to see the concrete failing checks and fix them
  2. Run formatters/linters prek is configured with and commit the results
  3. Refresh prek environments/caches (`prek run -a` or clearing its cache dir) after tool upgrades
  4. Fix or prune entries in the prek config that reference unavailable tools
  5. Use the tool's skip/bypass mechanism deliberately (e.g. env SKIP=... or push --no-verify) only when the failure is understood

Example fix

// before
$ git push
# prek pre-push validation failed
// after
$ prek run --all-files   # shows rustfmt failure in src/lib.rs
$ cargo fmt && git commit --amend --no-edit
$ git push
Defensive patterns

Strategy: retry

Validate before calling

// preflight: run the same validation before pushing
let ok = std::process::Command::new("prek")
    .args(["run", "--all-files"])
    .status()
    .map(|s| s.success())
    .unwrap_or(false);
if !ok { eprintln!("fix prek findings before pushing"); }

Try / catch

match run_hook_eval(...) {
    Ok(()) => {},
    Err(e) if e.to_string().contains("prek pre-push validation failed") => {
        eprintln!("prek checks failed; run `prek run --all-files` locally, fix, then push again");
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Calling `run_hook_eval` -> `run_prek_validation` when the prek subprocess finishes with a failing exit status: lint errors, formatting diffs, failing prek-managed hooks, or prek reporting 'no hooks configured' style failures depending on its config.

Common situations: Unformatted or lint-violating code staged for push; prek config (e.g. .pre-commit-config.yaml equivalent) referencing missing tools or versions; network fetch of hook environments failing; stale prek environment caches after a toolchain upgrade.

Related errors


AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01). Data as JSON: /api/errors/2394ca718cadecc2. Report an issue: GitHub.