runtime: return Workspace alongside lifecycle error from Engine.Up#56
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughEngine.Up now captures lifecycle errors and returns the created workspace alongside them when the error is a lifecycle error, and it always re-probes the user environment after lifecycle execution. A new test verifies the returned workspace and container remain reachable after a lifecycle failure. ChangesPreserve workspace on lifecycle failure
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Engine.Up dropped the just-created *Workspace whenever runAllLifecycle returned an error, returning (nil, err) and forcing every caller to treat a postCreateCommand bug as a fatal "workspace failed to start" condition — even though the container is created and still running. This diverges from @devcontainers/cli, which exits 1 on lifecycle failure but leaves the container intact and reattachable, the foundation of VS Code / Codespaces' "show a warning, keep the user in the container" UX. Return (ws, err) on lifecycle failure so callers can pick the policy: tear down, downgrade to warning, or reattach for debugging. *LifecycleError is the natural discriminator — no new sentinel needed. Non-lifecycle failures (image build, feature install, container create) still return (nil, err) unchanged. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
524e4d8 to
4b34fd6
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@up.go`:
- Around line 236-258: The current code returns (ws, lifecycleErr) for any error
from runAllLifecycle; change this to only return the workspace when the error is
a lifecycle-classified error: after calling runAllLifecycle and probeUserEnv,
test lifecycleErr with a type assertion or errors.As to see if it is a
*LifecycleError (or whatever concrete type you use for lifecycle failures) and
only then return (ws, lifecycleErr); for any other non-nil lifecycleErr return
(nil, lifecycleErr) (i.e., keep the usual if err != nil { return nil, err }
semantics) so non-lifecycle failures do not leak a running workspace.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: ce0701a9-37f5-470e-9cad-feb206c81212
📒 Files selected for processing (2)
lifecycle_test.goup.go
runAllLifecycle also surfaces marker I/O and context-cancellation errors. Those aren't the user-script-failed case the partial-success contract targets, so keep returning (nil, err) for them and only hand back the workspace when the error is a *LifecycleError. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Splitting the wsObj-nil check from the Container-nil check tripped staticcheck (it didn't follow t.Fatal as terminal). One combined short-circuit check is clearer and lint-clean. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Summary
Engine.Updropped the just-created*WorkspacewheneverrunAllLifecyclereturned an error, returning(nil, err)and forcing every caller to treat apostCreateCommandbug as a fatal "workspace failed to start" condition — even though the container is created and still running. This diverges from@devcontainers/cli, which exits 1 on lifecycle failure but leaves the container intact and reattachable, the foundation of VS Code / Codespaces' "show a warning, keep the user in the container" UX.(ws, err)instead of(nil, err). Callers pick the policy: tear down, downgrade to warning, or reattach for debugging.*LifecycleErroris already the natural discriminator — no new sentinel error needed.(nil, err)unchanged. Strict callers keep current behavior with the usualif err != nil { return nil, err }.Test plan
TestUp_LifecycleFailureReturnsWorkspace(unit): scripted runtime injects exit=17 for the postCreate hook; asserts (a)*LifecycleErrorsurfaces, (b) returned*Workspaceis non-nil with a realContainer.ID, (c) anExecagainst the returned workspace succeeds — proving the container wasn't torn down.TestUp_LifecycleErrorsSurfaceAsLifecycleErrorstill passes (error type/shape unchanged).go test ./...passes.🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Tests