fix(build): Handle unexpected throws in build-only tools#378
fix(build): Handle unexpected throws in build-only tools#378cameroncooke wants to merge 1 commit intomainfrom
Conversation
Wrap build-only executor xcodebuild invocations in try/catch so unexpected execution exceptions are converted into failed build domain results. Add focused regression tests for device, simulator, and macOS build-only tools to confirm thrown execution errors no longer escape the handler. Fixes #334 Co-Authored-By: OpenAI Codex <codex@openai.com>
| it('should return error result when executeXcodeBuildCommand throws unexpectedly', async () => { | ||
| const executeSpy = vi | ||
| .spyOn(buildUtils, 'executeXcodeBuildCommand') |
There was a problem hiding this comment.
Test uses vi.spyOn on imported module instead of injected dependency
This new test uses vi.spyOn(buildUtils, 'executeXcodeBuildCommand') to force a throw, rather than injecting a mock dependency through the executor parameter. The skill's guardrail requires unit tests to inject command/filesystem/external dependencies and prefer using existing mock executor helpers. Module-level spying couples the test to internal import structure and bypasses the dependency injection contract used elsewhere in this file (e.g., createMockExecutor, createSpyExecutor).
Verification
Reviewed the hunk and surrounding tests in the same describe block, which consistently inject createMockExecutor/createSpyExecutor per the skill's mock-executor helper guidance. The new test instead patches the buildUtils module export, which conflicts with the 'inject command/filesystem/external dependencies' and 'use existing mock executor helpers' guardrails. Could not verify whether buildDeviceLogic exposes a seam to inject executeXcodeBuildCommand directly without reading the source, so confidence is medium.
Identified by Warden xcodebuildmcp-test-boundary-review · DZ7-24F
commit: |
|
Closing this after re-auditing the actual xcodebuild execution path. The reported failure mode is already handled at the shared helper layer. Because build, test, and build-run tools all route through the same helper with different xcodebuild actions, adding per-tool The new tests in this PR forced an artificial failure mode by mocking No code change is needed here. If a real escaping path is found later, the fix should be proven and handled in |
Add defensive error handling for build-only tool execution paths.
Issue #334 called out that unexpected throws from the build execution layer could escape build-only tools. This change wraps
executeXcodeBuildCommandcalls in the three build-only executors (build_device,build_sim,build_macos) and converts those throws into failed build domain results, so callers get a structured failure instead of an unhandled exception.I considered adding a broader framework-level catch in
createSessionAwareTool, but that would affect every tool and increase regression risk. Keeping this change local to the three build-only executors is the smallest consistent fix for the reported gap.Also adds focused regression tests for each tool and updates
CHANGELOG.mdunder Unreleased.Fixes #334