Bug
zellij.Destroy treats ANY *exec.ExitError from zellij delete-session --force as "session already gone" and returns nil. But zellij can fail with non-zero exit for reasons other than "session not found" — corrupt socket, permission errors, version incompatibility, etc. This silently swallows real errors.
In the Create path (line ~141), a failed pre-cleanup Destroy is ignored, so the subsequent attach --create-background fails with a confusing "Session already exists" error instead of surfacing the real root cause.
Analyzed against: 96d1649 (current main)
Confidence: High — read the error handling path.
Root Cause
backend/internal/adapters/runtime/zellij/zellij.go:170-174:
func (z *Zellij) Destroy(ctx context.Context, handle ports.RuntimeHandle) error {
if err := z.cmd(ctx, "delete-session", "--force", handle.ID); err != nil {
var exitErr *exec.ExitError
if errors.As(err, &exitErr) {
return nil // <-- treats ALL non-zero exits as "already gone"
}
return err
}
return nil
}
Reproduction
- Corrupt the zellij socket directory permissions:
- Call
ao spawn — the Create path calls Destroy for pre-cleanup
zellij delete-session --force fails with permission denied (ExitError)
Destroy returns nil (swallowed)
attach --create-background fails with a confusing error about the session already existing
Alternative: set ZELLIJ_CONFIG_DIR to an invalid path, causing zellij to fail on startup.
Impact
- Real runtime failures are silently swallowed
- Users see misleading secondary errors instead of the root cause
- Debugging becomes harder: "Session already exists" when the real issue is a socket/permission problem
Suggested Fix
Check the stderr/exit message from zellij delete-session --force for the specific "session not found" pattern, rather than treating all non-zero exits as benign:
if errors.As(err, &exitErr) {
if bytes.Contains(exitErr.Stderr, []byte("No session")) ||
bytes.Contains(exitErr.Stderr, []byte("not found")) {
return nil
}
return fmt.Errorf("zellij delete-session: %w", err)
}
Bug
zellij.Destroytreats ANY*exec.ExitErrorfromzellij delete-session --forceas "session already gone" and returnsnil. But zellij can fail with non-zero exit for reasons other than "session not found" — corrupt socket, permission errors, version incompatibility, etc. This silently swallows real errors.In the
Createpath (line ~141), a failed pre-cleanupDestroyis ignored, so the subsequentattach --create-backgroundfails with a confusing "Session already exists" error instead of surfacing the real root cause.Analyzed against:
96d1649(currentmain)Confidence: High — read the error handling path.
Root Cause
backend/internal/adapters/runtime/zellij/zellij.go:170-174:Reproduction
chmod 000 /tmp/zellij-*ao spawn— theCreatepath callsDestroyfor pre-cleanupzellij delete-session --forcefails with permission denied (ExitError)Destroyreturns nil (swallowed)attach --create-backgroundfails with a confusing error about the session already existingAlternative: set
ZELLIJ_CONFIG_DIRto an invalid path, causing zellij to fail on startup.Impact
Suggested Fix
Check the stderr/exit message from
zellij delete-session --forcefor the specific "session not found" pattern, rather than treating all non-zero exits as benign: