fix(bugbot): move resolveCommonOpts into try/catch in 6 orchestration handlers#759
Merged
Merged
Conversation
…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.
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
Bugbot finding on (now-merged) PR #689:
resolveCommonOptswas awaited OUTSIDE the try block in all six orchestration handlers (tasks,task,sessions,session,resume,orchestration status). A rejection fromresolveCommonOpts(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 expectedExitCode.GENERAL_ERROR+emitJsonError/log.errorpath.This PR lifts the call inside
tryin each handler and uses optional chainingopts?.jsonOutputin catch blocks so a failure duringresolveCommonOptsitself 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
🤖 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 thetryblocks for six orchestration CLI handlers (tasks,task,sessions,session,resume, andorchestration status) so option-resolution failures are caught and reported consistently.Updates error paths to use
opts?.jsonOutputwhen emitting JSON errors, preventing crashes whenoptswas 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.