AIR CLI Integration: implement the air cancel command#5812
Merged
Conversation
Collaborator
Integration test reportCommit: 1cf6da6
8 interesting tests: 4 SKIP, 3 RECOVERED, 1 flaky
Top 20 slowest tests (at least 2 minutes):
|
4222f56 to
ecf2d77
Compare
ecf2d77 to
1cf6da6
Compare
Port the Python `handle_cancel` flow to the Go `air cancel` command: fill in PreRunE and RunE on the existing milestone-0 stub. - Cancel one or more runs by ID, or all of the current user's active runs with --all. - --all resolves the current user, lists their active runs via the ListTrainingWorkflows RPC (reusing listAirRuns), shows a preview table, and prompts for confirmation unless -y is set. - Cancellation goes through the typed SDK w.Jobs.CancelRun. - Per-run failures are collected and reported; not-found is detected with errors.Is(apierr.ErrResourceDoesNotExist). - Text and JSON (air envelope) output, exiting non-zero on any failure. Tests (testserver route, unit, and acceptance) follow in phase 2. Co-authored-by: Isaac
- Unit tests (cancel_test.go): arg validation, by-ID success/not-found, partial-failure JSON exit code, --all (no runs / confirm / abort), and the preview table. - Acceptance test (acceptance/experimental/air/cancel): by-ID text+JSON, multiple IDs, and --all -y, against stubbed CancelRun and ListTrainingWorkflows responses. - Drop the now-implemented cancel case from the stubs unit test and the unimplemented acceptance test. Co-authored-by: Isaac
- Add unit tests for the remaining branches: generic (non-not-found)
failure message, --all empty in JSON mode, --all current-user error,
--all list error, and a confirm-prompt read error.
- Fix two error strings that were capitalized ("Failed to ..." ->
"failed to ..."), per Go error-string convention.
cancel.go is now at ~93% line coverage; the only uncovered blocks are the
auth PreRunE wrapper (mirrors the get command, depends on real
MustWorkspaceClient) and a defensive renderEnvelope-error return.
Co-authored-by: Isaac
The Jobs cancel endpoint (POST /api/2.2/jobs/runs/cancel) returns 400 INVALID_PARAMETER_VALUE "Run <id> does not exist" for an unknown run. The SDK only remaps that to apierr.ErrResourceDoesNotExist for the runs/get path, so errors.Is(err, ErrResourceDoesNotExist) was false on cancel and the tailored not-found message never fired (it fell through to the generic "Failed to cancel run" branch). Add runNotFound(err) which also matches the raw 400 INVALID_PARAMETER_VALUE APIError via errors.AsType, restoring the Python CLI's friendly not-found guidance. Covered by a new unit test. Co-authored-by: Isaac
The list command exposes AIR runs via the Jobs-API run fetcher (newRunFetcher/next), not the old ListTrainingWorkflows RPC. Point `cancel --all` at it (fetching up to maxListScan active runs so every one is cancelled, not just the first page), and use the Jobs-API fakes (runsServer/runsListBody/airJobRun, jobs/runs/list) in the tests. Co-authored-by: Isaac
1cf6da6 to
827ff43
Compare
maggiewang-db
approved these changes
Jul 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Ports the Python
airCLI'shandle_cancelto the Goair cancelcommand (stacked onair-integration-m1-2).--all.--allresolves the current user, lists their active runs via the Jobs-API run fetcher, shows a preview table, and prompts for confirmation unless-yis set (fetches up tomaxListScanso every active run is cancelled).w.Jobs.CancelRun.errors.Is(apierr.ErrResourceDoesNotExist)and, for the cancel endpoint's400 INVALID_PARAMETER_VALUEshape, a typederrors.Ascheck — restoring the Python CLI's friendly "Run X not found" guidance.Tests
cancel_test.go): arg validation, by-ID success/not-found (both error shapes), partial-failure JSON exit code,--all(no runs / confirm / abort / read error), current-user + list errors, and the preview table.acceptance/experimental/air/cancel): by-ID text+JSON, multiple IDs, and--all -y.cancelcase from the stub unit test and theunimplementedacceptance test.This pull request and its description were written by Isaac.