Skip to content

fix: Error at plan when merge/squash commit title/message set with strategy disabled (alt. to #3556)#3558

Draft
ecerulm wants to merge 2 commits into
integrations:mainfrom
ecerulm:fix/3554-plan-error
Draft

fix: Error at plan when merge/squash commit title/message set with strategy disabled (alt. to #3556)#3558
ecerulm wants to merge 2 commits into
integrations:mainfrom
ecerulm:fix/3554-plan-error

Conversation

@ecerulm

@ecerulm ecerulm commented Jul 20, 2026

Copy link
Copy Markdown

Resolves #3554

Alternative approach. This is one of two proposed fixes for #3554. The other (#3556) suppresses the diff and emits an apply-time warning so the config silently converges. This PR takes the stricter route: it fails the plan with a clear error. Opened as a draft so maintainers can compare the two.


Background

merge_commit_title / merge_commit_message (and the squash_merge_commit_* equivalents) cannot be set on GitHub while the corresponding merge strategy is disabled. With allow_merge_commit = false, the REST API returns:

HTTP 422 Validation Failed
Sorry, you need to allow the merge commit strategy in order to set the default
merge commit message title and message. (no_merge_strategy)

The current provider avoids the 422 by simply not sending these fields when the strategy is off — but nothing tells the user, so the plan keeps showing a change that the apply silently never makes: perpetual, non-convergent drift.

After the change?

A CustomizeDiff validation fails the plan when the user has explicitly configured merge_commit_* / squash_merge_commit_* while the corresponding allow_merge_commit / allow_squash_merge is false:

Error: invalid github_repository configuration: "merge_commit_title" cannot be
set while allow_merge_commit is false. GitHub does not allow changing these
values while the corresponding merge strategy is disabled; remove them or
enable the strategy

Key details:

  • Only explicit config triggers it. "Configured" is detected via the raw config (GetRawConfig), i.e. the value is actually present in the user's .tf. Because merge_commit_* have schema defaults, a config that only sets allow_merge_commit = false and never mentions the title/message is not affected.
  • When the strategy is enabled, these fields behave exactly as before.
  • The error is at plan time (CustomizeDiff), so it's caught before any apply.

Trade-off vs #3556

#3556 (suppress + warn) This PR (error at plan)
Result Plan converges; ignored values, apply-time warning Plan fails with an explicit message
Signal timing Warning at apply (SDKv2 can't warn at plan) Error at plan
Behaviour change Non-breaking (previously-drifty config now converges) Potentially breaking: a config that previously applied (with drift) now fails to plan
Philosophy Be lenient, inform Be strict, force the user to fix the config

Verification

Verified against a real repository:

  • allow_merge_commit=false + merge_commit_title explicitly set → plan errors
  • allow_merge_commit=false, title/message not set → plan succeeds ✅ (no false positive)
  • allow_merge_commit=true + title set → plan succeeds

Pull request checklist

  • Schema migrations have been created if needed
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed

Does this introduce a breaking change?

  • Yes — a configuration that sets merge_commit_* / squash_merge_commit_* while the corresponding strategy is disabled will now fail at plan time (previously it applied with perpetual drift).
  • No

…rategy disabled

GitHub rejects any change to merge_commit_title/message (and the
squash_merge_commit_* equivalents) while the corresponding merge strategy
is disabled, returning HTTP 422 "no_merge_strategy". A config that both
disables a strategy and explicitly sets these values can therefore never
be applied.

Add a CustomizeDiff validation that fails the plan with a clear message
when the user has explicitly configured these fields (detected via the raw
config, so schema defaults do not trigger it) while allow_merge_commit /
allow_squash_merge is false. This surfaces the mistake at plan time
instead of producing a plan that silently never converges.

Alternative approach to integrations#3554 (see also the diff-suppression + warning
approach). Resolves integrations#3554
@github-actions

Copy link
Copy Markdown

👋 Hi, and thank you for this contribution!

This repo is maintained by GitHub and community members on a best-effort basis. We'll get to this as soon as we can.

You can help us prioritize by joining the discussion on open issues and PRs, sharing details on the changes you need, and reviewing other contributions.


🤖 This is an automated message.

@github-actions github-actions Bot added the Type: Bug Something isn't working as documented label Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Bug Something isn't working as documented

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: github_repository reports drift on merge_commit_message and merge_commit_title if allow_merge_commit is false

1 participant