ref:main

ci job-view: contextualize log-stream errors so it's clear metadata succeeded #9

closed Opened by cole.christensen@gmail.com

Links

No links yet.

Problem

When `anvil ci job-view ` fails to fetch logs (e.g. against a server that returns 406 from the log endpoint), the output is:

``` CI Job 7a1731da43 Name clippy Status passed Step 3 Duration 59.0s Runner carl Exit Code 0 Started 2026-05-01 14:42:26 Completed 2026-05-01 14:43:25

Error: API error (406): server returned an HTML error page (expected JSON) ```

Two issues with this:

  1. The bare `Error: API error (406)` makes it look like the whole command failed, even though the metadata block above it was retrieved successfully.
  2. The message doesn’t mention "logs" — the user has to know that `job-view` makes two API calls (metadata, then log stream) to interpret it.

Proposed fix

Wrap the `stream_job_logs` call in `commands/ci.rs:362` so its error is reported with context. Something like:

``` Could not fetch logs: API error (406): server returned an HTML error page (expected JSON). The job metadata above was retrieved successfully; the server refused the log stream. ```

(or similar — short, but distinguishing the failed step from the succeeded one).

The rest of the CLI’s error handling (where there’s no preceding partial output) stays as-is.

Acceptance criteria

  • When `stream_job_logs` errors, the user sees a message that mentions logs specifically and acknowledges the metadata succeeded
  • When metadata fetch fails, behavior is unchanged (the metadata header was never printed, so contextualizing the log error isn’t needed)
  • Existing client tests pass

Priority

Low. Cosmetic. Cleanup after fangorn/anvil-cli#13 + fangorn/anvil#205.