feat(ci): add diagnose command#506
Merged
Merged
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Autofix Details
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: TruncatedContextFields serializes as null instead of empty array
- Changed line 637 to use make([]string, 0, len(...)) to guarantee a non-nil slice that serializes as [] instead of null, matching the nil-context guard and other array fields.
Or push these changes by commenting:
@cursor push 36e7c44691
Preview (36e7c44691)
diff --git a/pkg/cmd/ci/diagnose.go b/pkg/cmd/ci/diagnose.go
--- a/pkg/cmd/ci/diagnose.go
+++ b/pkg/cmd/ci/diagnose.go
@@ -613,6 +613,8 @@
if context == nil {
return diagnoseContextJSON{TruncatedContextFields: []string{}}
}
+ truncatedFields := make([]string, 0, len(context.GetTruncatedContextFields()))
+ truncatedFields = append(truncatedFields, context.GetTruncatedContextFields()...)
return diagnoseContextJSON{
RunID: context.GetRunId(),
Repo: context.GetRepo(),
@@ -634,7 +636,7 @@
Attempt: context.GetAttempt(),
AttemptStatus: context.GetAttemptStatus(),
AttemptConclusion: context.GetAttemptConclusion(),
- TruncatedContextFields: append([]string(nil), context.GetTruncatedContextFields()...),
+ TruncatedContextFields: truncatedFields,
}
}You can send follow-ups to the cloud agent here.
89f292c to
3551bb9
Compare
3551bb9 to
180881c
Compare
b1fd5bb to
8624f9c
Compare
8624f9c to
8ebec37
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Empty-string conflation suppresses differing representative errors
- Added non-empty check to else-if condition at line 305 to distinguish between 'no errors' and 'different errors', preventing suppression of differing representative error messages.
Or push these changes by commenting:
@cursor push 872e3d894f
Preview (872e3d894f)
diff --git a/pkg/cmd/ci/diagnose.go b/pkg/cmd/ci/diagnose.go
--- a/pkg/cmd/ci/diagnose.go
+++ b/pkg/cmd/ci/diagnose.go
@@ -302,7 +302,7 @@
if representativeError != "" && representativeError != group.GetErrorMessage() {
fmt.Fprintf(w, " Where: %s\n", representativeError)
showRepresentativeErrors = false
- } else if representativeError == group.GetErrorMessage() {
+ } else if representativeError != "" && representativeError == group.GetErrorMessage() {
showRepresentativeErrors = false
}
if group.GetDiagnosis() != "" {You can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit 6d1310f. Configure here.
PeterHeja
approved these changes
May 13, 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
The CLI keeps the human command as
depot ci diagnose: pass a failed run, workflow, job, or attempt id and it renders the API'sFailureDiagnosisresponse into a readable triage summary.Review guide
This looks larger than it is because generated protobuf/OpenAPI output is included.
Please skip generated files.
Human review surface:
pkg/cmd/ci/diagnose.goWhat was happening
Users could get logs and summaries, but the CLI did not have a first-class way to ask which failure mattered. Matrix jobs made that worse because several attempts could fail or cancel for the same underlying reason, and repeating every representative drill-down again in a footer made large diagnoses noisy.
What happens now
depot ci diagnose <id>with automatic target resolution and--output json.--type run|workflow|job|attemptdisambiguation flag for rare ID collisions.depot ci logs/depot ci summarycommands.Next commandsfooter; text output keeps those commands under the representative attempt where they are useful.Showing 3 of 7 similar attempts for this group.so bounded output looks intentional instead of incomplete.Sample Response
Validation
make generatego test ./pkg/cmd/ci ./pkg/apigo test ./pkg/cmd/ci -run Diagnosego test ./pkg/cmd/cigo test ./...git diff --checkgo build -o bin/depot-dev ./cmd/depotmake bin/depotDEPOT_API_URL=http://localhost:18080 ./bin/depot ci diagnose h5753524rz --org cl0wyyk6k39487ebgraxasinjaDEPOT_API_URL=http://127.0.0.1:18080 ./bin/depot-dev ci diagnose cvhm9dnf32:next_commands=0,logs=13,summaries=0Depends on https://github.com/depot/api/pull/3656.
Linear: https://linear.app/depot/issue/DEP-4264/ci-diagnose-failure-triage-for-runs-workflows-jobs-and-attempts
Note
Medium Risk
Adds a new CI API wrapper and a sizable new
depot ci diagnosecommand with custom text/JSON rendering logic; primary risk is output/UX correctness and handling of bounded/truncated API responses, but it doesn’t touch auth flows beyond existing token/org headers.Overview
Adds a new
CIGetFailureDiagnosisAPI wrapper and wires it into a newdepot ci diagnosesubcommand for diagnosing failed runs/workflows/jobs/attempts.The command validates exactly one target selector, calls the failure-diagnosis endpoint, and renders either human-readable triage output (grouped/focused/over-limit/empty states, representative attempts, evidence, and drill-down commands) or normalized JSON (stringified enums, bounds/capabilities, and machine-safe
argv).Includes comprehensive tests for the new API wrapper and CLI formatting/edge-cases (org flag propagation, omission of unavailable summary commands, evidence filtering, and truncation/bounds behavior).
Reviewed by Cursor Bugbot for commit ba30e6f. Bugbot is set up for automated code reviews on this repo. Configure here.