Skip to content

fix(cli): let an explicit pid drop a configured bundleId (#551) - #553

Open
vsolano9 wants to merge 1 commit into
getsentry:mainfrom
vsolano9:fix/551-attach-pid-session-default
Open

vsolano9 wants to merge 1 commit into
getsentry:mainfrom
vsolano9:fix/551-attach-pid-session-default

Conversation

@vsolano9

Copy link
Copy Markdown
Contributor

Fixes #551.

Cause

On the CLI path, register-tool-commands.ts merges the configured session defaults into the explicit arguments (mergeCliSessionDefaults) before it calls the tool handler. That merge drops a defaulted key when the user passes the other key of an exclusive pair, but the CLI's own pair list only had projectPath/workspacePath and simulatorId/simulatorName. debug_attach_sim declares ['bundleId', 'pid'] as exclusive, so with sessionDefaults.bundleId set, debugging attach --pid <pid> reached the handler with both keys as explicit arguments and failed the mutual-exclusion check. Over MCP the handler's own merge already drops the default, which is why only the CLI was affected.

Change

  • Add ['bundleId', 'pid'] to CLI_SESSION_DEFAULT_EXCLUSIVE_PAIRS, so an explicit pid drops the configured bundleId (and an explicit bundleId would drop a defaulted pid). The list is typed as ExclusiveParameterGroup[] because pid is not a session-default key.
  • Two regression tests in src/cli/__tests__/session-defaults.test.ts: --pid with a configured bundleId, and --json '{"pid":…,"bundleId":null}'. Both fail on main and pass with the change.
  • CHANGELOG entry under [Unreleased].

debug_attach_sim is the only tool that declares pid, and passing bundleId and pid together explicitly is still rejected by the handler.

Testing

On macOS 26 (arm64), Node 26.11:

  • npm run build, npm run typecheck, npm run lint, npm run format:check: all pass.
  • npm test: 243 files, 2593 tests passed. The pre-commit hook passed on the commit.
  • Real CLI against a booted simulator, with .mobilebuildmcp/config.yaml setting sessionDefaults.bundleId and simulatorId, then node build/cli.js debugging attach --simulator-id <udid> --pid <pid> --continue-on-attach true --output json:
    • main: Parameter validation failed: Invalid parameters: Mutually exclusive parameters provided: bundleId, pid. (MUTUALLY_EXCLUSIVE_PARAMETERS)
    • this branch: validation passes and the attach targets the given processId. In my run, lldb then declined because the session was non-interactive over ssh (cannot get permission to debug processes), which is a local debugger-permission limit, not part of this change.

I also went through the mobilebuildmcp-runtime-boundary-review guardrails by hand (shared handlers and routing.stateful daemon routing are unchanged; the daemon receives the already-merged args). The warden CLI was not available here, so that review was not run through Warden.

This change was prepared with AI assistance (Claude Code); the checks above were run as described.

🤖 Generated with Claude Code

The CLI merges session defaults into the explicit args before the tool
handler checks mutually exclusive pairs, and the CLI's own pair list did
not include bundleId/pid. With sessionDefaults.bundleId set,
`debugging attach --pid` reached debug_attach_sim with both keys and was
rejected. Add the pair so an explicit pid drops the defaulted bundleId,
as the MCP path already does.
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

This PR has been inactive for 21 days. It will be closed in 7 days if no further activity occurs. Add a comment to keep it open, or apply the no-stale label.

@vsolano9

vsolano9 commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

Still current as of today's main (2998ac7): CLI_SESSION_DEFAULT_EXCLUSIVE_PAIRS in src/cli/session-defaults.ts still lists only projectPath/workspacePath and simulatorId/simulatorName, so #551 still reproduces.

I merged this branch onto 2998ac7 (no conflicts) and reran npx vitest run src/cli/__tests__/session-defaults.test.ts: 11/11 pass. With main's session-defaults.ts swapped back in, the two new regression tests fail (drops a configured bundleId when the user attaches by pid, ... when JSON args pass pid with a null bundleId) and the other 9 pass.

Happy to rebase or adjust anything if that helps review.

@github-actions github-actions Bot removed the stale-pr label Nov 8, 2026
@vsolano9

Copy link
Copy Markdown
Contributor Author

A quick CI update: the fork workflow for this PR is marked failed, but it recorded zero jobs, so there is no test failure to diagnose. The linked issue #551 was also closed by the stale bot on November 20.

Could a maintainer help queue a fresh CI run and add no-stale while this is waiting for review? The comment above has the local regression results. I can refresh the branch if GitHub needs a new head to dispatch the workflow.

This branch has not been deployed

No deployments
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.

[Bug]: CLI debugging attach --pid rejected when sessionDefaults set bundleId

1 participant