Stop paying for the task list when the API serves logs #270

Merged
stephen merged 1 commit from feat/actions-log-api into main 2026-09-11 09:30:16 +00:00
Owner

fj run view --log reads job logs from /api/v1/repos/{o}/{r}/actions/jobs/{id}/logs on Forgejo 16, with a plain API token. It was still fetching the workflow task list first and then discarding it. That call is not cheap on 16: /actions/tasks ignores its run filter there, so it answers with every task in the repository. Against a private repo on 16.0.3 that is 3.2 MB and about 30 seconds, paid on every single log read.

Only the Loki fallback ever needed task metadata (the per-task container name and the query window). It now comes from a TaskSource that loads on first ask, so the native path never asks at all. The task id the output reports on that path comes from the jobs payload, which carries it inline.

Two related things the 16 path got wrong, fixed here because the same change surfaces them:

  • parse_workflow_tasks did not know about the workflow_runs envelope the task list actually arrives in, so the Loki fallback aborted with "unexpected workflow task list response shape" rather than falling back.
  • private_log_auth_error and the workflow_view.rs module header both still said the API log route does not exist and rejects token auth. That was true of 15.0.2 and is not true of 16.0.3. They now say which version does what, so the message points at --log instead of sending the user to the web UI.

15.x loses nothing. The API route 404s there and the run falls through to Loki exactly as it did before, which is the behaviour the existing fallback tests cover.

Refs #103.

Verified on macOS: cargo fmt --check clean, cargo clippy --all-targets --all-features -- -D warnings clean, cargo test --all green (797 + 5 + 1), cargo audit clean.

`fj run view --log` reads job logs from `/api/v1/repos/{o}/{r}/actions/jobs/{id}/logs` on Forgejo 16, with a plain API token. It was still fetching the workflow task list first and then discarding it. That call is not cheap on 16: `/actions/tasks` ignores its `run` filter there, so it answers with every task in the repository. Against a private repo on 16.0.3 that is 3.2 MB and about 30 seconds, paid on every single log read. Only the Loki fallback ever needed task metadata (the per-task container name and the query window). It now comes from a `TaskSource` that loads on first ask, so the native path never asks at all. The task id the output reports on that path comes from the jobs payload, which carries it inline. Two related things the 16 path got wrong, fixed here because the same change surfaces them: - `parse_workflow_tasks` did not know about the `workflow_runs` envelope the task list actually arrives in, so the Loki fallback aborted with "unexpected workflow task list response shape" rather than falling back. - `private_log_auth_error` and the `workflow_view.rs` module header both still said the API log route does not exist and rejects token auth. That was true of 15.0.2 and is not true of 16.0.3. They now say which version does what, so the message points at `--log` instead of sending the user to the web UI. 15.x loses nothing. The API route 404s there and the run falls through to Loki exactly as it did before, which is the behaviour the existing fallback tests cover. Refs #103. Verified on macOS: `cargo fmt --check` clean, `cargo clippy --all-targets --all-features -- -D warnings` clean, `cargo test --all` green (797 + 5 + 1), `cargo audit` clean.
fix(run): stop paying for the task list when the API serves logs
All checks were successful
ci / check (pull_request) Successful in 11m31s
ci / live-e2e (pull_request) Successful in 2m1s
ci / coverage (pull_request) Successful in 2m23s
fa541518fe
Forgejo 16 serves job logs from `/api/v1/repos/{o}/{r}/actions/jobs/{id}/logs`
with a plain API token, which is the path `fj run view --log` takes there. It
was still fetching the workflow task list first and then throwing the result
away: `/actions/tasks` ignores its `run` filter on 16, so that call answers
with every task in the repository. Measured against a private repo on 16.0.3:
3.2 MB and about 30 seconds, on every log read.

Only the Loki fallback needs task metadata (the per-task container name and
the query window), so it is now fetched behind a `TaskSource` that loads on
first ask, and the native path never asks. The task id the output reports on
that path comes from the jobs payload instead, which carries it inline.

Two things that path gets wrong on 16 are fixed alongside:

  * `parse_workflow_tasks` did not know the `workflow_runs` envelope the task
    list actually comes back in, so the Loki fallback aborted with "unexpected
    workflow task list response shape".
  * `private_log_auth_error` and the `workflow_view.rs` module header still
    described the API log route as nonexistent and token-rejecting, which was
    true of 15.0.2 and is not true of 16.0.3. Both now say which version does
    what, so the message points at `--log` rather than at the web UI.

15.x keeps every fallback it had: the API route 404s there, and the run falls
through to Loki exactly as before.

Refs rasterstate/fj#103
Sign in to join this conversation.
No description provided.