runatlantis / atlantis

Terraform Pull Request Automation
https://www.runatlantis.io
Other
7.78k stars 1.05k forks source link

Improper markdown formatting with multi-comment plan outputs #1097

Open dmattia opened 4 years ago

dmattia commented 4 years ago

We are noticing some cases where our plans appear to skip over many plans because of invalid markdown.

As an example, we recently ran atlantis over a PR that affected ~150 modules. Here is the end of one comment:

### 85. dir: `infra/datadog/agent_container/env-prod` workspace: `default`
```diff
Validated that dmattia is an admin

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:

Terraform will perform the following actions:

Plan: 0 to add, 0 to change, 0 to destroy.

Warning: Output length greater than max comment size. Continued in next comment.


And then in the next comment it continues with:

```markdown
Continued from previous comment.
<details><summary>Show Output</summary>

```diff
orward: To **apply** this plan, comment:
    * `atlantis apply -d infra/datadog/agent_container/env-prod`
* :put_litter_in_its_place: To **delete** this plan click [here](https://atlantis.ci.transcend.io/lock?id=transcend-io%252Fmain%252Finfra%252Fdatadog%252Fagent_container%252Fenv-prod%252Fdefault)
* :repeat: To **plan** this project again, comment:
    * `atlantis plan -d infra/datadog/agent_container/env-prod`

---
### 86. dir: `infra/datadog/agent_container/env-prod/secrets` workspace: `default`
```diff
Validated that dmattia is an admin

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:

Terraform will perform the following actions:

Plan: 0 to add, 0 to change, 0 to destroy.

This causes the plan to appear to jump forward and skip quite a number of outputs:

Screen Shot 2020-06-26 at 4 17 06 PM

If I go to "edit" the comment in between the jump, I can see all of the missing job outputs

lkysow commented 4 years ago

So this is as a result of our logic for splitting comments being naive and assuming that we're splitting in the middle of a plan/apply output. In your case we ended up splitting in the middle of the commands output and so when we apply

```diff

it borks all the markdown.

I think the true fix here is for the markdown renderer to return a struct that describes the output better rather than just a string. Then the splitting functionality can be smarter about where it splits long comments.

angeloskaltsikis commented 4 years ago

It seems we are facing the current issue as well. I really like the elegant solution that @lkysow is suggesting here and i think this will straight solve the https://github.com/runatlantis/atlantis/issues/1021 as well. What do you think? I can also spend some time on this matter to make those problems go away 😄

jamengual commented 2 years ago

is this still an issue with v0.19.8?

dmattia commented 2 years ago

It appears to be