From 7813eb081a3b68e1a77932f7d3dfd31b47a422f5 Mon Sep 17 00:00:00 2001 From: gilesb Date: Tue, 13 Jan 2026 03:57:36 +0000 Subject: [PATCH] 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 --- legacy_tasks.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/legacy_tasks.py b/legacy_tasks.py index 87232ad..5b39415 100644 --- a/legacy_tasks.py +++ b/legacy_tasks.py @@ -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'}")