Skip to content

AIR CLI Integration: implement the air cancel command#5812

Merged
riddhibhagwat-db merged 5 commits into
air-clifrom
air-integration-m3-1
Jul 6, 2026
Merged

AIR CLI Integration: implement the air cancel command#5812
riddhibhagwat-db merged 5 commits into
air-clifrom
air-integration-m3-1

Conversation

@riddhibhagwat-db

Copy link
Copy Markdown

Summary

Ports the Python air CLI's handle_cancel to the Go air cancel command (stacked on air-integration-m1-2).

  • 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 Jobs-API run fetcher, shows a preview table, and prompts for confirmation unless -y is set (fetches up to maxListScan so every active run is cancelled).
  • Cancellation goes through the typed SDK w.Jobs.CancelRun.
  • Not-found is detected via errors.Is(apierr.ErrResourceDoesNotExist) and, for the cancel endpoint's 400 INVALID_PARAMETER_VALUE shape, a typed errors.As check — restoring the Python CLI's friendly "Run X not found" guidance.
  • Text and JSON (air envelope) output; exits non-zero on any failure.

Tests

  • Unit (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 (acceptance/experimental/air/cancel): by-ID text+JSON, multiple IDs, and --all -y.
  • Drops the now-implemented cancel case from the stub unit test and the unimplemented acceptance test.

This pull request and its description were written by Isaac.

@eng-dev-ecosystem-bot

eng-dev-ecosystem-bot commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Integration test report

Commit: 1cf6da6

Run: 28811532190

Env 🔄​flaky 💚​RECOVERED 🙈​SKIP ✅​pass 🙈​skip Time
💚​ aws linux 4 4 267 1026 5:55
💚​ aws windows 4 4 269 1024 5:49
💚​ aws-ucws linux 4 4 363 940 6:43
💚​ aws-ucws windows 4 4 365 938 7:19
💚​ azure linux 4 4 264 1026 5:03
💚​ azure windows 4 4 266 1024 6:31
💚​ azure-ucws linux 4 4 362 938 6:50
🔄​ azure-ucws windows 1 3 4 364 936 8:02
💚​ gcp linux 4 4 260 1029 5:44
💚​ gcp windows 4 4 262 1027 6:55
8 interesting tests: 4 SKIP, 3 RECOVERED, 1 flaky
Test Name aws linux aws windows aws-ucws linux aws-ucws windows azure linux azure windows azure-ucws linux azure-ucws windows gcp linux gcp windows
💚​ TestAccept 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R
🙈​ TestAccept/bundle/invariant/no_drift 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/vector_search_endpoints/drift/recreated_same_name 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/vector_search_indexes/recreate/embedding_dimension 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/ssh/connection 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🔄​ TestFetchRepositoryInfoAPI_FromRepo 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 🔄​f 💚​R 💚​R
💚​ TestFetchRepositoryInfoAPI_FromRepo/root 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R
💚​ TestFetchRepositoryInfoAPI_FromRepo/subdir 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R
Top 20 slowest tests (at least 2 minutes):
duration env testname
4:49 gcp windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
4:30 gcp linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
4:27 gcp windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
4:15 gcp linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
3:51 azure-ucws linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
3:10 aws linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
3:09 aws linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
3:08 azure-ucws windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
3:08 aws-ucws windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
3:07 aws windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
3:05 azure linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:56 azure windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:55 azure-ucws linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:53 aws-ucws linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:52 azure linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:44 aws-ucws windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:40 azure-ucws windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:39 aws-ucws linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:36 azure windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:26 aws windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct

@riddhibhagwat-db riddhibhagwat-db changed the base branch from air-integration-m1-2 to air-list-fast July 6, 2026 17:30
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
@riddhibhagwat-db riddhibhagwat-db changed the base branch from air-list-fast to air-cli July 6, 2026 18:48
@riddhibhagwat-db riddhibhagwat-db merged commit 18fed34 into air-cli Jul 6, 2026
5 checks passed
@riddhibhagwat-db riddhibhagwat-db deleted the air-integration-m3-1 branch July 6, 2026 22:17
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.

3 participants