fix: compose up must exit non-zero when the AI debugger runs - #2228
Conversation
handleComposeUpErr returned the DEBUGGER's error. The debugger returns nil once it has explained the failure, so any fatal ComposeUp error became exit code 0 for accounts that auto-approve the debugger — which is exactly the paid accounts whose CI runs it unattended. The deploy step went green on a deploy that never happened; only a downstream smoke test noticed. Run the debugger for its side effect and always return the deployment error, the same shape session.go already uses for compose load errors. Fixes #2227 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review. 📝 WalkthroughWalkthroughThe compose error handler now returns the deployment error after debugger execution. Debugger failures are logged. Tests cover auto-approve and non-auto-approve account paths using an injectable debugger agent. ChangesCompose error preservation
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to The CLI will now exit non-zero when compose deployment fails even if the AI debugger runs; the localized change is covered by focused tests, and no actionable merge-blocking risk remains. Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
main gained #2228 (compose up must exit non-zero when the AI debugger runs), which touches the same functions as the review fixes on this branch. Kept main's fix: the debugger runs for its side effect and handleComposeUpErr returns the original error. Its regression test survives the reconciliation and still fails with "got <nil>" if the fix is reverted. Reconciled the removal of the paid-tier gate with that test's needs. The gate is gone, so the debugger is no longer built at all when there is nobody to prompt, but #2228 needs it injectable to test how the caller handles its result. The handlers now take a debuggerFactory that is only called once the caller knows it will use one, which satisfies both: no agent connection in CI, and a stub in tests. NewDebuggerForTest loses its defaultPermission argument. TestHandleComposeUpErrWithoutAutoApprove becomes TestHandleComposeUpErrNonInteractiveSkipsTheDebugger: with no tier gate, the thing worth asserting is that CI never builds a debugger, and still gets the deployment error. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01T3WmpdY3zc555sNdkY9dzQ
Fixes #2227.
The bug
handleComposeUpErrreturned the debugger's error:promptAndTrackDebugSessionreturnsnilonce the debug session finishes, so afatal
ComposeUperror came back asniland the CLI exited 0.It only bites accounts that auto-approve the debugger. The guard above it,
if global.NonInteractive && !debugger.AutoApprove(), sends free-tier CIstraight out with the error — so the false green hits exactly the paid accounts
whose CI runs the debugger unattended, including Defang's own.
The fix
Run the debugger for its side effect and always return the deployment error.
That is the shape the neighbouring paths already use:
handleTailAndMonitorErrreturns nothing and its caller returns
deploymentErr, andsession.goreturnsloadErrafterDebugComposeLoadError.handleTooManyProjectsErrorstill returns nil after a successful interactivecompose down— that one is a deliberate recovery, and it is untouched.Tests
TestHandleComposeUpErrKeepsTheDeploymentErrorcovers the CI auto-approve pathfor both a debugger that succeeds and one that fails;
TestHandleComposeUpErrWithoutAutoApprovecovers the free-tier path. Revertingthe one-line change fails the first with
expected the original deployment error, got <nil>— the reported symptom exactly.NewDebuggerForTestis new:NewDebuggerneeds a live Fabric connection, sotests outside
pkg/debughad no way to build aDebugger.🤖 Generated with Claude Code
https://claude.ai/code/session_01T3WmpdY3zc555sNdkY9dzQ
Summary by CodeRabbit