fix(catalyst-ui): ExecutionLogs uses API_BASE so /api/ → /sovereign/api/ routes correctly (#305 follow-up 4) (#332)

Pre-existing bug exposed by #305: ExecutionLogs fetched
`/api/v1/actions/executions/{id}/logs` directly instead of going
through API_BASE (`${BASE}api`). Under Vite's `/sovereign/` base path,
the Traefik ingress only routes `/sovereign/api/...` — bare `/api/...`
returns 404.

Live evidence after #328 (jobId raw colon fix):
  GET /sovereign/api/v1/deployments/.../jobs/{id} → 200  (FE rewire OK)
  GET /api/v1/actions/executions/{realExecId}/logs → 404 (this bug)

Note that the executionId in the failing URL is a real 32-char hex
(5f59cb0bc9df2c720b4cf07989e4dc4f), not the synthetic `:latest` —
proving the rewire in #307 + the colon fix in #328 both worked. Only
the logs URL prefix remained wrong.

Fix: import API_BASE; use `${API_BASE}/v1/actions/executions/...`.
Per docs/INVIOLABLE-PRINCIPLES.md #4 (never hardcode URLs in app
source) — the original direct `/api/...` was a violation that this
PR settles permanently.

Co-authored-by: hatice yildiz <hatice.yildiz@openova.io>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
e3mrah 2026-04-30 23:15:29 +04:00 committed by GitHub
parent aa77537be1
commit 4f80be232a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -31,6 +31,7 @@
import { useEffect, useMemo, useRef, useState } from 'react'
import { useQuery } from '@tanstack/react-query'
import { API_BASE } from '@/shared/config/urls'
/* ── Types ──────────────────────────────────────────────────────── */
@ -99,7 +100,11 @@ async function defaultFetchLogs({
fromLine: String(fromLine),
limit: String(limit),
})
const res = await fetch(`/api/v1/actions/executions/${executionId}/logs?${params}`)
// API_BASE resolves to `${BASE}api`; under the /sovereign/ Vite
// base this becomes `/sovereign/api`, which the Traefik ingress
// routes correctly. A bare `/api/v1/...` (the previous shape) was
// not routed at all — every log fetch returned 404. See #305.
const res = await fetch(`${API_BASE}/v1/actions/executions/${executionId}/logs?${params}`)
if (!res.ok) {
throw new Error(`Failed to fetch logs: ${res.status}`)
}