close
Skip to content

fix: prevent diffKeywordRegex from falsely matching YAML key=value list items in heredocs#6422

Merged
jamengual merged 1 commit into
runatlantis:mainfrom
GMartinez-Sisti:fix/diff-regex-yaml-heredoc-false-positive
Apr 23, 2026
Merged

fix: prevent diffKeywordRegex from falsely matching YAML key=value list items in heredocs#6422
jamengual merged 1 commit into
runatlantis:mainfrom
GMartinez-Sisti:fix/diff-regex-yaml-heredoc-false-positive

Conversation

@GMartinez-Sisti
Copy link
Copy Markdown
Member

Summary

  • diffKeywordRegex was matching YAML list items like - ServerSideApply=true (used in ArgoCD syncOptions) as Terraform diff markers, causing false removals to appear in PR comments even when there was no actual plan change.
  • Fix: require \s=\s (spaces around =) instead of bare = — Terraform HCL attribute assignments always use =, while YAML key=value pairs never do.
  • Added a regression test covering an ArgoCD Application resource with syncOptions in a heredoc.

Closes #6419

Root Cause

Introduced in #6069, which changed the operator alternation in diffKeywordRegex from \s=\s to =. This broadened matching to unintentionally cover YAML list items of the form - Key=Value inside heredoc strings.

Test plan

  • Added failing test (argocd application with yaml key=value list items in heredoc) that reproduces the false positive before the fix
  • All TestDiffMarkdownFormattedTerraformOutput tests pass after the fix, including all CloudFormation cases added in fix: diff cloudformation stack list items #6069

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings April 23, 2026 22:35
@dosubot dosubot Bot added bug Something isn't working go Pull requests that update Go code labels Apr 23, 2026
@GMartinez-Sisti GMartinez-Sisti force-pushed the fix/diff-regex-yaml-heredoc-false-positive branch from 47e88ea to aca9e1b Compare April 23, 2026 22:36
…st items in heredocs

Terraform HCL attribute assignments always use spaces around = (` = `),
so requiring `\s=\s` instead of bare `=` in diffKeywordRegex is correct.
YAML list items like `- ServerSideApply=true` (used in ArgoCD syncOptions)
were being falsely treated as Terraform diff removal markers, causing them
to appear as removals in PR comments even when no change was present.

Closes runatlantis#6419

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Gabriel Martinez <gabrielmartinez@sisti.pt>
@GMartinez-Sisti GMartinez-Sisti force-pushed the fix/diff-regex-yaml-heredoc-false-positive branch from aca9e1b to e1fada7 Compare April 23, 2026 22:36
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a regression where diffKeywordRegex treated YAML key=value list items inside heredocs (e.g., ArgoCD syncOptions) as Terraform diff markers, leading to false “removed” lines in Atlantis PR comments.

Changes:

  • Tightened diffKeywordRegex to require whitespace around = (\s=\s) so YAML key=value items are no longer matched.
  • Added a regression test case reproducing the ArgoCD heredoc scenario and asserting the diff formatter preserves the YAML list item correctly.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
server/events/models/models.go Narrows diffKeywordRegex matching for assignments to avoid false positives on YAML key=value within heredocs.
server/events/models/models_test.go Adds a regression test covering ArgoCD syncOptions: - ServerSideApply=true inside a heredoc.

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Apr 23, 2026
@jamengual jamengual merged commit ec601e3 into runatlantis:main Apr 23, 2026
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working go Pull requests that update Go code lgtm This PR has been approved by a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

regression: diffKeywordRegex falsely matches YAML list items (key=value) inside heredocs since #6069

3 participants