Skip to content

Add setting_sources input and default base-action to user-only - #1115

Open
km-anthropic wants to merge 6 commits into
mainfrom
setting-sources-default
Open

km-anthropic wants to merge 6 commits into
mainfrom
setting-sources-default

Conversation

@km-anthropic

@km-anthropic km-anthropic commented Mar 24, 2026 •

Copy link
Copy Markdown
Collaborator

Changes the base-action default for settingSources from ["user","project","local"] to ["user"], and adds a setting_sources input so callers can opt back in to project/local settings.

With the new default, project-level .claude/settings.json is not read unless explicitly enabled. The MCP integration tests are updated to opt in via setting_sources: "user,project" (for the .mcp.json discovery test) and to use claude_args: --mcp-config (for the flag test).

Comment thread action.yml Resolved
OctavianGuzu added a commit that referenced this pull request Apr 23, 2026
Adds an enable_all_project_mcp_servers action input so workflow authors
explicitly opt in to auto-loading servers from the checkout's .mcp.json.
The wrapper action keeps a 'true' default since it restores .mcp.json
from the PR base ref before execution, so wrapper-action behavior is
unchanged.

Complements #1115 (setting_sources default).

:house: Remote-Dev: homespace
OctavianGuzu
OctavianGuzu previously approved these changes Apr 23, 2026
@OctavianGuzu

Copy link
Copy Markdown
Collaborator

@km-anthropic — bump on this one. Sister PR #1250 applies the same opt-in pattern to enableAllProjectMcpServers (and ties the wrapper default to whether config was restored from base). Would be good to land both together so consumers see one defaults change.

km-anthropic and others added 2 commits April 23, 2026 17:05
Project and local settings additively merge their permissions with whatever
allowed_tools a workflow specifies. A workflow author writing a restrictive
allowlist reasonably expects it to be the complete allow-set, but
.claude/settings.json can silently expand it.

Changes:
- Add setting_sources as a first-class input to both actions (previously
  only reachable via --setting-sources in claude_args)
- base-action now defaults to settingSources: ['user'] — workflows that want
  project/local settings must opt in explicitly
- Main action defaults to 'user,project,local' since .claude/ is restored
  from the PR base branch before execution, so project settings are
  maintainer-trusted in that context
- Precedence: setting_sources input > --setting-sources in claude_args > default

Breaking change for base-action: workflows relying on .claude/settings.json
being loaded automatically need to add setting_sources: 'user,project,local'.


:house: Remote-Dev: homespace
- test-mcp-integration: opt in to project settings so .mcp.json is discovered
- test-mcp-config-flag: replace removed mcp_config input with claude_args --mcp-config

:house: Remote-Dev: homespace
Keeps the input default empty so claude_args --setting-sources is not
shadowed; the wrapper applies user,project,local as the runtime fallback,
base-action applies user.

:house: Remote-Dev: homespace
Defaults to user-only under pull_request_target/workflow_run; otherwise
keeps user,project,local. Wrapper's runtime default unchanged.

:house: Remote-Dev: homespace
Comment thread base-action/README.md Resolved
@OctavianGuzu
OctavianGuzu requested a review from ddworken April 23, 2026 17:28

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks — the README now has the "see below" paragraph and the issue_comment gating, so my earlier notes are addressed. I'm not auto-approving since this changes security-relevant setting-source defaults (and the wrapper's hardcoded defaultSettingSources bypasses the event gate by design); a maintainer should sign off on the defaults policy, ideally alongside #1250.

Extended reasoning...

Overview

This PR adds a setting_sources input to both action.yml and base-action/action.yml, threads it through run-claude.ts / index.ts / run.ts, and rewrites the settingSources resolution in parse-sdk-options.ts to a three-tier precedence (direct input → --setting-sources in claude_args → caller-supplied or event-gated default). It also updates the MCP integration tests and base-action README, and adds ~10 unit tests covering the new precedence and event gating.

Security risks

The core of this change is security-relevant: settingSources controls whether in-repo .claude/settings.json (which can additively expand the permission allowlist) is loaded. The base-action now defaults to ['user'] under pull_request_target / workflow_run / issue_comment, which is a hardening. However, the wrapper (src/entrypoints/run.ts) passes defaultSettingSources: ['user','project','local'] unconditionally, intentionally bypassing the event gate on the rationale that .claude/ is restored from the PR base branch first. That rationale is documented in the input description, but it is a security policy decision that should be confirmed by a maintainer rather than auto-approved.

Level of scrutiny

High. This is a behavior change to defaults that affect every consumer of both the base-action and the wrapper, touches the permission-loading surface, and the author has explicitly requested maintainer review and coordination with sister PR #1250. It is not a mechanical or obviously-correct change.

Other factors

  • Both of my prior inline comments have been addressed: the YAML default is now empty (12f457a) so claude_args --setting-sources is reachable, and the README's dangling "(see below)" now has a corresponding paragraph (added with 044a103).
  • Test coverage for the new precedence logic is solid, including the empty-string fallthrough case that mirrors the YAML default.
  • No new bugs were found by the bug-hunting system on this revision.
  • The author bumped a specific maintainer and asked to land this together with #1250, which further indicates human coordination is expected before merge.

Comment thread src/entrypoints/run.ts
Comment on lines +284 to +289
// Only assert that project/local config is safe to load when it was actually
// restored from the base branch above. Otherwise leave undefined so
// parseSdkOptions applies its event-gated default.
defaultSettingSources: configRestoredFromBase
? ["user", "project", "local"]
: undefined,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔴 This regresses the common "@claude on a plain issue" flow: issue_comment on a non-PR issue has context.isPR === false, so configRestoredFromBase stays false, defaultSettingSources is left undefined, and parseSdkOptions applies the event-gated default of ['user'] — silently dropping .claude/settings.json and .mcp.json that loaded before this PR. The checkout there is the trusted default branch (and the issues event still gets project,local), so the restriction isn't security-motivated; consider also setting defaultSettingSources when isEntityContext(context) && !context.isPR.

Extended reasoning...

What the bug is

Commit b6dac6f changed the wrapper to only pass defaultSettingSources: ['user','project','local'] when configRestoredFromBase is true. That flag is only set inside the if (isEntityContext(context) && context.isPR) block. For an issue_comment event fired on a plain issue (the canonical "@claude please do X" tag-mode entry point), context.isPR is Boolean(payload.issue.pull_request) → false (src/github/context.ts:188). The block is skipped, configRestoredFromBase stays false, and defaultSettingSources is passed as undefined.

parseSdkOptions then falls through to the event-gated fallback: GITHUB_EVENT_NAME === 'issue_comment' matches, so settingSources resolves to ['user']. Before this PR the fallback was unconditionally ['user','project','local'], so this is a behavior regression.

Step-by-step proof

  1. User comments @claude implement feature X on issue Getting API Error: 404 when use_bedrock: "true" #42 (not a PR).
  2. GitHub fires issue_comment with payload.issue.pull_request undefined.
  3. parseGitHubContext → isPR = Boolean(undefined) = false.
  4. run.ts:245 — isEntityContext(context) && context.isPR → true && false → block skipped; configRestoredFromBase = false.
  5. run.ts:287 — defaultSettingSources: false ? [...] : undefined → undefined.
  6. parse-sdk-options.ts — options.settingSources is "" (falsy), no --setting-sources in claude_args, options.defaultSettingSources is undefined, so ?? falls through to the event check.
  7. process.env.GITHUB_EVENT_NAME === 'issue_comment' → returns ['user'].
  8. Claude runs without loading .claude/settings.json (project permissions/hooks) or .mcp.json.

Why nothing prevents it

The restoreConfigFromBase machinery exists to sanitize PR checkouts where .claude/ is attacker-controlled. For issue_comment on a plain issue, the checkout is the repo's default branch — trusted maintainer content — so there is nothing to restore from and no attacker-controlled config to defend against. The new gating conflates "config was restored from base" with "config is trusted", missing the case where the checkout is already the trusted base.

Why it looks unintentional

The issues event (opened/labeled/assigned) is not in the gated list and still gets ['user','project','local']. So adding the claude label to an issue loads project settings, but commenting @claude on the same issue does not. The action.yml description says the wrapper "applies the same event-gated default as base-action for other contexts" without calling out that this drops project/local for the most common tag-mode trigger.

Impact

Users who rely on .claude/settings.json for project-level permission allowlists, hooks, or .mcp.json MCP servers will see them silently stop working when @claude is invoked on plain issues. No error is surfaced — tools/hooks/servers just disappear.

How to fix

In run.ts, also pass defaultSettingSources: ['user','project','local'] for the non-PR entity path, e.g.:

defaultSettingSources:
  configRestoredFromBase || (isEntityContext(context) && !context.isPR)
    ? ['user', 'project', 'local']
    : undefined,

(or equivalently set a separate configIsTrusted flag that covers both "restored from base" and "checkout is the default branch").

OctavianGuzu added a commit that referenced this pull request Apr 25, 2026
Adds an enable_all_project_mcp_servers action input so workflow authors
explicitly opt in to auto-loading servers from the checkout's .mcp.json.
The wrapper action keeps a 'true' default since it restores .mcp.json
from the PR base ref before execution, so wrapper-action behavior is
unchanged.

Complements #1115 (setting_sources default).

:house: Remote-Dev: homespace

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.

2 participants