{"record":{"id":"43b88d444a68abb7","repo":"nikivdev/code","slug":"ai-task-failed-with-status","errorCode":null,"errorMessage":"AI task '{}' failed with status {}","messagePattern":"AI task '(.+?)' failed with status (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/ai_tasks.rs","lineNumber":272,"sourceCode":"    }\n}\n\npub fn run_task_via_moon(\n    task: &DiscoveredAiTask,\n    project_root: &Path,\n    args: &[String],\n) -> Result<()> {\n    let mut cmd = moon_run_command(task, project_root, args);\n    let status = cmd.status().with_context(|| {\n        format!(\n            \"failed to run AI task {} via moon ({})\",\n            task.id,\n            task.path.display()\n        )\n    })?;\n\n    if !status.success() {\n        bail!(\"AI task '{}' failed with status {}\", task.id, status);\n    }\n    Ok(())\n}\n\npub fn run_task_via_moon_output(\n    task: &DiscoveredAiTask,\n    project_root: &Path,\n    args: &[String],\n) -> Result<Output> {\n    let mut cmd = moon_run_command(task, project_root, args);\n    let output = cmd.output().with_context(|| {\n        format!(\n            \"failed to run AI task {} via moon ({})\",\n            task.id,\n            task.path.display()\n        )\n    })?;\n    Ok(output)","sourceCodeStart":254,"sourceCodeEnd":290,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/ai_tasks.rs#L254-L290","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Read the task's stdout/stderr output printed above the error to find the real failure","Run the task's underlying moon target manually to reproduce and debug","Fix the task script or its environment, then re-run"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match run_task_via_moon(task, root, args) {\n    Ok(()) => Ok(()),\n    Err(e) if e.to_string().contains(\"failed with status\") => {\n        eprintln!(\"Task '{}' failed; see output above for root cause.\", task.id);\n        Err(e)\n    }\n    Err(e) => Err(e),\n}","preventionTips":["Capture and inspect the task's stdout/stderr before interpreting the status","Test moon tasks standalone before wiring them into AI task runners","Make task scripts exit with meaningful codes"],"tags":["process-exit","moon","task-runner","subprocess"],"backgroundTag":"nonzero-exit-status","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}