Skip to content

fix(bugbot): move resolveCommonOpts into try/catch in 6 orchestration handlers#759

Merged
kelsonpw merged 1 commit into
mainfrom
fix/orchestration-commands-resolve-in-try
May 13, 2026
Merged

fix(bugbot): move resolveCommonOpts into try/catch in 6 orchestration handlers#759
kelsonpw merged 1 commit into
mainfrom
fix/orchestration-commands-resolve-in-try

Conversation

@kelsonpw
Copy link
Copy Markdown
Member

@kelsonpw kelsonpw commented May 13, 2026

Summary

Bugbot finding on (now-merged) PR #689: resolveCommonOpts was awaited OUTSIDE the try block in all six orchestration handlers (tasks, task, sessions, session, resume, orchestration status). A rejection from resolveCommonOpts (e.g. process.cwd() failed because cwd was deleted, dynamic import failed) propagated as an unhandled promise rejection — Node terminated with exit 1 and no structured error output instead of the expected ExitCode.GENERAL_ERROR + emitJsonError / log.error path.

This PR lifts the call inside try in each handler and uses optional chaining opts?.jsonOutput in catch blocks so a failure during resolveCommonOpts itself routes through the same JSON-error / human-error reporting as any other failure.

Why post-merge

PR #689 merged with this Bugbot Low-severity finding unresolved. Cleaning it up as a tiny follow-up rather than reopening #689.

Test plan

  • tsc clean
  • all 8 orchestration CLI smoke tests pass with the new shape

🤖 Generated with Claude Code


Note

Low Risk
Low risk change confined to CLI error-handling paths; main behavior is unchanged except failures during option resolution now produce structured JSON/human errors instead of unhandled rejections.

Overview
Moves resolveCommonOpts() inside the try blocks for six orchestration CLI handlers (tasks, task, sessions, session, resume, and orchestration status) so option-resolution failures are caught and reported consistently.

Updates error paths to use opts?.jsonOutput when emitting JSON errors, preventing crashes when opts was never successfully resolved and ensuring the commands exit with the intended error codes.

Reviewed by Cursor Bugbot for commit 59b332e. Bugbot is set up for automated code reviews on this repo. Configure here.

…lers

resolveCommonOpts was awaited OUTSIDE the try block in each of:
tasksCommand, taskCommand, sessionsCommand, sessionCommand,
resumeCommand, and `orchestration status`. If it rejected
(process.cwd() failed, dynamic import failed, or an unexpected throw
from mode-config / install-dir resolution), the rejection propagated
out of the `void (async () => {...})()` wrapper as an unhandled
promise. Node terminated with exit 1 and no structured error output,
instead of the expected ExitCode.GENERAL_ERROR + emitJsonError /
log.error path that the rest of the handler honors.

Lift the call inside try and use optional chaining `opts?.jsonOutput`
in catch blocks so a failure during resolveCommonOpts itself routes
through the same JSON-error / human-error reporting as any other
failure in the command body.

Bugbot finding on PR #689 (merged); fixing post-merge.
@kelsonpw kelsonpw requested a review from a team as a code owner May 13, 2026 04:36
@kelsonpw kelsonpw merged commit 533155f into main May 13, 2026
11 checks passed
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.

1 participant