Skip to content

Add --task flag to logs and artifacts commands for task key resolution#426

Merged
robinaugh merged 5 commits intomainfrom
jason/rwx-148-add-cli-support-for-passing-task-keys-to-logsartifacts
Mar 17, 2026
Merged

Add --task flag to logs and artifacts commands for task key resolution#426
robinaugh merged 5 commits intomainfrom
jason/rwx-148-add-cli-support-for-passing-task-keys-to-logsartifacts

Conversation

@robinaugh
Copy link
Contributor

@robinaugh robinaugh commented Mar 16, 2026

Summary

  • Add --task <key> flag to rwx logs, rwx artifacts list, and rwx artifacts download that resolves tasks by key (e.g., ci.checks.lint) instead of requiring a task ID
  • When --task is used, run ID can be provided as a positional arg or inferred from git context (same logic as rwx results)
  • New API methods call non-nested routes (/mint/api/log_download, /mint/api/artifact_downloads) with run_id + task_key query params
  • Handles 422 (ambiguous key) by displaying the server-provided message, and 404 (not found) with descriptive messages
  • Existing positional task-ID interface is fully preserved for backward compatibility

Blocked by server-side PR: https://github.com/rwx-cloud/cloud/pull/7083

Test plan

  • Verify rwx logs <taskId> still works (backward compat)
  • Verify rwx logs --task ci.checks.lint infers run ID from git and downloads logs
  • Verify rwx logs <run-id> --task lint with explicit run ID
  • Verify rwx artifacts list --task <key> and rwx artifacts list <run-id> --task <key>
  • Verify rwx artifacts download --task <key> <artifact-key> and with explicit run-id
  • Verify rwx artifacts download --task <key> --all
  • Verify ambiguous key (422) displays server-provided message with partial matches
  • Verify not-found key (404) displays helpful error
  • Verify error when --task is used without git context and no run-id provided

@robinaugh robinaugh self-assigned this Mar 16, 2026
@robinaugh robinaugh force-pushed the jason/rwx-148-add-cli-support-for-passing-task-keys-to-logsartifacts branch 4 times, most recently from a8437f1 to f1bd4c9 Compare March 16, 2026 17:53
@robinaugh robinaugh marked this pull request as ready for review March 16, 2026 18:11
…e it

Extract the git branch/repo → latest run ID resolution into a shared
service method so it can be reused by other commands. Refactor
results.go to use it instead of inlining the same logic.
Support resolving tasks by key (e.g., ci.checks.lint) instead of task ID
for rwx logs, rwx artifacts list, and rwx artifacts download. When --task
is used, the run ID can be provided as a positional arg or inferred from
git context via the shared ResolveRunIDFromGitContext helper.

Also migrates existing log/artifact API methods to use the new non-nested
routes (/mint/api/log_download, /mint/api/artifact_downloads) for
consistency with the task-key variants.

Handles ambiguous keys (422) by displaying matching fully-qualified keys
and not-found errors (404) with descriptive messages.
When --task is used and the server returns a not-found error, the CLI
now suggests running `rwx results --all` (or `rwx results <run-id> --all`
when the run ID was provided explicitly) to discover available task keys.
…_key

Preserve ErrNotFound sentinel through the service and command layers so
telemetry classifies task-key not-found errors as "not_found" instead of
"unknown". Add ErrAmbiguousTaskKey sentinel and wire it through
AmbiguousTaskKeyError so ambiguous key errors are classified as
"ambiguous_task_key".
@robinaugh robinaugh force-pushed the jason/rwx-148-add-cli-support-for-passing-task-keys-to-logsartifacts branch from f1bd4c9 to c39e031 Compare March 17, 2026 15:00
Instead of constructing the ambiguous task key message client-side
from matching_keys, display the message returned by the server's 422
response directly. Remove the `rwx results --all` suggestion from
task key error handling.
@robinaugh robinaugh force-pushed the jason/rwx-148-add-cli-support-for-passing-task-keys-to-logsartifacts branch from c39e031 to b7cfdf6 Compare March 17, 2026 15:29
@robinaugh robinaugh merged commit 2aa2bde into main Mar 17, 2026
1 check passed
@robinaugh robinaugh deleted the jason/rwx-148-add-cli-support-for-passing-task-keys-to-logsartifacts branch March 17, 2026 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants