Skip to content

Conversation

@kamal
Copy link
Contributor

@kamal kamal commented Feb 8, 2026

As a follow up to #203, this adds support for persisting custom environment variables into session defaults

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 8, 2026

Open in StackBlitz

npm i https://pkg.pr.new/getsentry/XcodeBuildMCP/xcodebuildmcp@207

commit: 40bc529

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 8, 2026

Walkthrough

This pull request introduces support for environment variables in session defaults. The changes extend the session defaults schema by adding an optional env field to store environment variable mappings as records of strings. The SessionDefaults type is updated to include the new env property, and the sessionDefaultKeys array is extended with the 'env' key. Test coverage is added to verify that environment defaults are stored correctly and persisted to configuration files when required. Additionally, the version is updated from '2.0.0-beta.1' to '2.0.0', marking a stable release.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding support for persisting custom environment variables in session defaults.
Description check ✅ Passed The description is directly related to the changeset, referencing issue #203 and explaining the purpose of adding environment variable persistence to session defaults.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


No actionable comments were generated in the recent review. 🎉

🧹 Recent nitpick comments
src/utils/session-store.ts (1)

30-31: Shallow merge replaces the entire env object on each setDefaults call.

Because setDefaults uses object spread ({ ...this.defaults, ...partial }), calling it with a new env value will replace — not merge — the previous environment variables map. For example, setting { env: { A: '1' } } followed by { env: { B: '2' } } results in only { B: '2' }.

This is consistent with how all other keys behave, but worth confirming it matches the intended UX for environment variables, where users might expect additive/incremental updates.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cameroncooke
Copy link
Collaborator

@kamal Thanks for this, would you mind fixing up the typecheck issue. In general it's recommended you install the pre-commit hook into this repo see: https://github.com/cameroncooke/XcodeBuildMCP/blob/main/docs/dev/CONTRIBUTING.md#local-development-setup

@kamal kamal force-pushed the allow-set-env-on-session-defaults branch from 3a47f1f to 40bc529 Compare February 11, 2026 07:53
Copy link
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 3 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

// (user-provided keys take precedence on conflict)
if (sessionDefaults.env && typeof sanitizedArgs.env === 'object' && sanitizedArgs.env) {
merged.env = { ...sessionDefaults.env, ...(sanitizedArgs.env as Record<string, string>) };
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Env validation bypass via deep merge

Medium Severity

The env deep-merge guard treats any object-like value as mergeable, so arrays or other non-record objects in sanitizedArgs.env get spread into merged.env before internalSchema.parse. When session defaults contain env, invalid user input can be silently accepted or transformed instead of failing validation.

Fix in Cursor Fix in Web

// (user-provided keys take precedence on conflict)
if (sessionDefaults.env && typeof sanitizedArgs.env === 'object' && sanitizedArgs.env) {
merged.env = { ...sessionDefaults.env, ...(sanitizedArgs.env as Record<string, string>) };
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty env cannot override defaults

Medium Severity

When sessionDefaults.env exists, passing env: {} no longer overrides defaults. The deep-merge branch rebuilds merged.env from default values, so explicit empty env input is ignored and tools still receive session-level variables.

Fix in Cursor Fix in Web

preferXcodebuild?: boolean;
platform?: string;
bundleId?: string;
env?: Record<string, string>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mutable env leaks through session store

Medium Severity

Adding env as Record<string, string> introduces shared-reference state in sessionStore. setDefaults/getAll are shallow, so mutating a previously passed or retrieved env object can silently change stored defaults without calling sessionStore.setDefaults, bypassing revision tracking.

Fix in Cursor Fix in Web

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.

2 participants