Fail run if output cannot be uploaded to IPFS

- Upload final output to IPFS after execution completes
- Return success=False if IPFS upload fails
- Previously the run would succeed with output_ipfs_cid=None

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
gilesb
2026-01-13 03:57:36 +00:00
parent 0f4817e3a8
commit 7813eb081a

View File

@@ -1019,6 +1019,34 @@ def execute_recipe(self, recipe_sexp: str, input_hashes: Dict[str, str], run_id:
output_ipfs_cid = output_result.get("ipfs_cid")
output_path = output_result.get("path")
# Upload final output to IPFS if not already there
if output_path and not output_ipfs_cid:
output_path_obj = Path(output_path) if isinstance(output_path, str) else output_path
if output_path_obj.exists():
logger.info(f"Uploading final output to IPFS: {output_path}")
output_ipfs_cid = ipfs_client.add_file(str(output_path_obj))
if output_ipfs_cid:
logger.info(f"Uploaded output to IPFS: {output_ipfs_cid}")
else:
logger.error(f"Failed to upload output to IPFS: {output_path}")
# Fail if output couldn't be uploaded to IPFS
if not output_ipfs_cid:
logger.error(f"Recipe failed: Could not upload output to IPFS! output_cid={output_cid}, output_path={output_path}")
return {
"success": False,
"run_id": run_id,
"error": "Failed to upload output to IPFS",
"plan_cid": plan_cid,
"plan_sexp": plan_sexp,
"output_cid": output_cid,
"output_path": output_path,
"step_results": step_results,
"total_steps": len(plan.steps),
"cached": total_cached,
"executed": total_executed,
}
# Fail if no output was produced
if not output_cid:
logger.error(f"Recipe produced no output! output_step={plan.output_step_id}, result={output_result if output_step else 'no output step'}")