nikivdev/code · error

could not resolve commit report directory

Error message

could not resolve commit report directory

What it means

Thrown when preparing the commit report directory: flow_commit_reports_dir() returned None, so the code cannot determine where to write commit/review reports. It is a configuration/environment resolution failure, before any files are written.

Source

Thrown at src/commit.rs:4834

        if !trimmed.is_empty() {
            return Some(PathBuf::from(trimmed));
        }
    }
    dirs::home_dir().map(|home| home.join(".flow").join("commits"))
}

fn write_commit_review_markdown_report(
    repo_root: &Path,
    review: &ReviewResult,
    reviewer: &str,
    model_label: &str,
    committed_sha: Option<&str>,
    commit_message: &str,
    review_run_id: &str,
    review_todo_ids: &[String],
) -> Result<PathBuf> {
    let Some(report_dir) = flow_commit_reports_dir() else {
        bail!("could not resolve commit report directory");
    };
    fs::create_dir_all(&report_dir)?;

    let project_name = flow_project_name(repo_root);
    let branch = git_capture_in(repo_root, &["rev-parse", "--abbrev-ref", "HEAD"])
        .unwrap_or_else(|_| "unknown".to_string())
        .trim()
        .to_string();
    let sha_short = committed_sha.map(short_sha).unwrap_or("unknown");
    let stamp = chrono::Utc::now().format("%Y%m%d_%H%M%S").to_string();
    let file_name = format!(
        "{}-{}-{}-{}.md",
        safe_label_value(&project_name),
        safe_label_value(&branch),
        sha_short,
        stamp
    );
    let path = report_dir.join(file_name);

View on GitHub (pinned to a747e741ae)

Solutions

  1. Set the configuration/env that flow_commit_reports_dir() reads (e.g. the myflow reports-dir setting) and rerun.
  2. Run the command from inside an initialized project so the reports directory can be derived from the repo/workspace.
  3. In CI, ensure HOME and XDG_CONFIG_HOME/XDG_DATA_HOME are set.
  4. Initialize myflow config (`f auth` / project init) before committing.

Example fix

// shell, before
unset HOME  # or minimal docker env
// after
export HOME=/home/user
export XDG_DATA_HOME=$HOME/.local/share
Defensive patterns

Strategy: validation

Validate before calling

fn ensure_report_dir_ready() -> anyhow::Result<std::path::PathBuf> {
    let dir = flow_commit_reports_dir()
        .ok_or_else(|| anyhow::anyhow!("reports dir not configured; set myflow reports-dir config"))?;
    std::fs::create_dir_all(&dir)?;
    Ok(dir)
}

Type guard

fn reports_dir_configured() -> bool {
    flow_commit_reports_dir().is_some()
}

Prevention

When it happens

Trigger: Calling the commit report writer function when flow_commit_reports_dir() cannot resolve a base directory (env/config not set and no default discoverable).

Common situations: Running the CLI outside an initialized myflow workspace; missing or empty config entry for the reports dir; HOME/XDG env vars unset in CI or containers so the default path can't be derived.

Understand the failure class

Background: "missing required config value" errors: why libraries refuse to start when a configuration key is empty, unset, or blank — this error's family across 48 libraries.

Related errors


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