nikivdev/code · error

AI task '{}' failed with status {}

Error message

AI task '{}' failed with status {}

What it means

Thrown by run_task_via_moon in src/ai_tasks.rs after it spawns the AI task through the moon build system and the child process exits with a non-zero status. It reports the task ID and the raw exit status.

Source

Thrown at src/ai_tasks.rs:272

    }
}

pub fn run_task_via_moon(
    task: &DiscoveredAiTask,
    project_root: &Path,
    args: &[String],
) -> Result<()> {
    let mut cmd = moon_run_command(task, project_root, args);
    let status = cmd.status().with_context(|| {
        format!(
            "failed to run AI task {} via moon ({})",
            task.id,
            task.path.display()
        )
    })?;

    if !status.success() {
        bail!("AI task '{}' failed with status {}", task.id, status);
    }
    Ok(())
}

pub fn run_task_via_moon_output(
    task: &DiscoveredAiTask,
    project_root: &Path,
    args: &[String],
) -> Result<Output> {
    let mut cmd = moon_run_command(task, project_root, args);
    let output = cmd.output().with_context(|| {
        format!(
            "failed to run AI task {} via moon ({})",
            task.id,
            task.path.display()
        )
    })?;
    Ok(output)

View on GitHub (pinned to a747e741ae)

Solutions

  1. Read the task's stdout/stderr output printed above the error to find the real failure
  2. Run the task's underlying moon target manually to reproduce and debug
  3. Fix the task script or its environment, then re-run
Defensive patterns

Strategy: try-catch

Try / catch

match run_task_via_moon(task, root, args) {
    Ok(()) => Ok(()),
    Err(e) if e.to_string().contains("failed with status") => {
        eprintln!("Task '{}' failed; see output above for root cause.", task.id);
        Err(e)
    }
    Err(e) => Err(e),
}

Prevention

When it happens

Trigger: run_task dispatches to run_task_via_moon when the task has no workspace, and the spawned moon task process terminates with a failure exit code.

Common situations: Task script has a bug or panics; missing dependencies in the moon workspace; failing tests or lint steps inside the task; wrong exit codes propagated from nested tools.

Related errors


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