Fix run detail: default to JSON, only HTML if browser requests it

API clients like Python requests send Accept: */* which wasn't
matching wants_json(). Switch to checking wants_html() instead
so API clients get JSON by default.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
gilesb
2026-01-11 22:03:53 +00:00
parent c6fadea090
commit 50ea0f1491

View File

@@ -100,15 +100,16 @@ async def get_run(
if not run:
raise HTTPException(404, f"Run {run_id} not found")
if wants_json(request):
return run
# Only render HTML if browser explicitly requests it
if wants_html(request):
templates = get_templates(request)
return render(templates, "runs/detail.html", request,
run=run,
active_tab="runs",
)
# Render HTML detail page
templates = get_templates(request)
return render(templates, "runs/detail.html", request,
run=run,
active_tab="runs",
)
# Default to JSON for API clients
return run
@router.delete("/{run_id}")