diff --git a/CHANGELOG.md b/CHANGELOG.md index f47e609a..34fd4fab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## [Unreleased] + +### Fixed + +- Fixed `mobilebuildmcp debugging attach --pid` failing with "Mutually exclusive parameters provided: bundleId, pid" when the project's session defaults set `bundleId`. An explicit `pid` now drops the configured `bundleId` on the CLI, as it already did over MCP ([#551](https://github.com/getsentry/MobileBuildMCP/issues/551)). + ## [2.7.1] ### Changed diff --git a/src/cli/__tests__/session-defaults.test.ts b/src/cli/__tests__/session-defaults.test.ts index f30f298c..e23c1913 100644 --- a/src/cli/__tests__/session-defaults.test.ts +++ b/src/cli/__tests__/session-defaults.test.ts @@ -73,6 +73,39 @@ describe('CLI session defaults', () => { }); }); + it('drops a configured bundleId when the user attaches by pid', () => { + const merged = mergeCliSessionDefaults({ + defaults: { + bundleId: 'com.example.App', + simulatorId: 'SIM-1', + }, + explicitArgs: { + pid: 4242, + }, + }); + + expect(merged).toEqual({ + simulatorId: 'SIM-1', + pid: 4242, + }); + }); + + it('drops a configured bundleId when JSON args pass pid with a null bundleId', () => { + const merged = mergeCliSessionDefaults({ + defaults: { + bundleId: 'com.example.App', + }, + explicitArgs: { + pid: 4242, + bundleId: null, + }, + }); + + expect(merged).toEqual({ + pid: 4242, + }); + }); + it('prefers simulatorId when both simulator defaults come only from config', () => { const merged = mergeCliSessionDefaults({ defaults: { diff --git a/src/cli/session-defaults.ts b/src/cli/session-defaults.ts index 0097a630..0f5a8a25 100644 --- a/src/cli/session-defaults.ts +++ b/src/cli/session-defaults.ts @@ -5,11 +5,15 @@ import type { SessionDefaults } from '../utils/session-store.ts'; import { mergeSessionDefaultArgs, pickSessionDefaultsForKeys, + type ExclusiveParameterGroup, } from '../utils/session-default-args.ts'; -const CLI_SESSION_DEFAULT_EXCLUSIVE_PAIRS: (keyof SessionDefaults)[][] = [ +// Mirrors the exclusive pairs the tool handlers declare: an explicit value for one key drops the +// configured default for the other, so a merged default never collides with an explicit argument. +const CLI_SESSION_DEFAULT_EXCLUSIVE_PAIRS: readonly ExclusiveParameterGroup[] = [ ['projectPath', 'workspacePath'], ['simulatorId', 'simulatorName'], + ['bundleId', 'pid'], ]; export function resolveCliSessionDefaults(opts: {