Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lists of yaml strings are interpreted as deletion in Markdown-converted Terraform plans #5332

Open
luca-poddigue-hs opened this issue Feb 14, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@luca-poddigue-hs
Copy link

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request. Searching for pre-existing feature requests helps us consolidate datapoints for identical requirements into a single place, thank you!
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Overview of the Issue

We use Terraform to send a bunch of Prometheus alert manager rules to AWS Managed Prometheus. These rules are configured in multiple yaml files: we read and combine them in Terraform to get single strings, and we assign the strings to the related Terraform resources.

Some of these rules contain yaml lists of strings (example in the reproduction steps). If we run a plain Terraform plan, Terraform correctly interprets them, and reports no changes if the lists items are unchanged.

In Atlantis, we enabled enable-diff-markdown-format: true to get colored diffs in GitHub PRs. In order to produce these diffs, it is my understanding that Atlantis takes the vanilla Terraform plan and performs some regexp-based manipulations to convert it into a GitHub-compliant Markdown format.

The problem we ran into is that specific yaml lists of strings from our Prometheus rules are matched by the Atlantis regexp and interpreted as a deletion, so in our PRs we get a bunch of apparently deleted list items, that are actually unchanged, and make it extremely harder to review the actual changes.

Reproduction Steps

This is an excerpt of a rule file that is causing the issue (look at the matchers list items):

- receiver: pobs-priority-slack
  group_by: ['...']
  matchers:
    - severity = warn
    - priority = high
    - team = pobs

I sort of reproduced the issue via Regex101 here. The regexp comes from the Atlantis source code, and the test string is a random item taken from a random matchers list. I think the problem is given by the combination of the leading - char, combined with the =.

Environment details

  • Atlantis version: 0.31.0
  • Deployment method: ecs
  • If not running the latest Atlantis version have you tried to reproduce this issue on the latest version: no

Atlantis server-side config file:

write-git-creds: false

automerge: true
disable-autoplan: false

parallel-apply: true
parallel-plan: true
parallel-pool-size: 6

allow-commands: "version,plan,apply,approve_policies,unlock"
repo-config: "/home/atlantis/config/repos.yaml"
enable-policy-checks: true
quiet-policy-checks: true
checkout-strategy: merge
emoji-reaction: rocket
enable-diff-markdown-format: true

locking-db-type: "redis"
redis-tls-enabled: true

Repo atlantis.yaml file:

terraform_version: 1.3.2
file_types: ["alert.rules/*.yml", "alertmanager.rules/*.yml", "recording.rules/*.yml", "**/*.tf", "**/*.tfvars"]
@luca-poddigue-hs luca-poddigue-hs added the bug Something isn't working label Feb 14, 2025
Copy link

dosubot bot commented Feb 14, 2025

Hey @luca-poddigue-hs! I'm here to help you with any bugs, questions, or contributions you have. Let's tackle this together!

The issue you're experiencing with YAML lists being interpreted as deletions in Markdown-converted Terraform plans is likely due to the way Atlantis processes the plan output for Markdown formatting. Specifically, the combination of a leading - character and the = sign in your YAML lists might be triggering a regular expression that Atlantis uses to format the output.

Currently, there isn't a specific workaround or configuration in Atlantis to prevent this misinterpretation directly. However, you might consider the following approaches:

  1. Modify the YAML Format: If possible, adjust the format of your YAML lists to avoid the pattern that triggers the regex. For example, you could try using a different character or format that doesn't start with -.

  2. Custom Atlantis Configuration: Review your Atlantis configuration to see if there are any options that might affect how diffs are generated. Although there isn't a direct setting to change this behavior, ensuring that your configuration is up-to-date and optimized might help.

  3. Atlantis Version Update: Consider testing with the latest version of Atlantis, as there might be updates or fixes related to Markdown formatting that could address this issue.

  4. Regex Adjustment: If you have the capability to modify the Atlantis source code, you could adjust the regular expression responsible for this behavior. However, this requires a good understanding of the codebase and the potential impact of such changes.

These suggestions are based on the current understanding of how Atlantis processes Terraform plans into Markdown format [1][2].

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant