Fix artifact dict key mismatch (hash -> cid)

Template runs/detail.html expects artifact.cid but code provided
artifact.hash, causing UndefinedError when viewing run details.

- Change run_service.get_run_artifacts to return 'cid' key
- Change runs.py router inline artifact creation to use 'cid' key
- Add regression tests for artifact data structure

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
gilesb
2026-01-12 12:05:13 +00:00
parent 585c75e846
commit 977d9a9258
3 changed files with 59 additions and 2 deletions

View File

@@ -258,7 +258,7 @@ async def get_run(
except Exception:
pass
artifacts.append({
"hash": output_cid,
"cid": output_cid,
"step_name": "Output",
"media_type": media_type or "application/octet-stream",
})

View File

@@ -547,7 +547,7 @@ class RunService:
path = self.cache.get_by_cid(cid)
if path and path.exists():
return {
"hash": cid,
"cid": cid,
"size_bytes": path.stat().st_size,
"media_type": detect_media_type(path),
"role": role,