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

maximum commenter_input length? #32

Open
jsimoni opened this issue May 3, 2022 · 2 comments
Open

maximum commenter_input length? #32

jsimoni opened this issue May 3, 2022 · 2 comments

Comments

@jsimoni
Copy link

jsimoni commented May 3, 2022

I started getting the following error
Error: An error occurred trying to start process '/usr/bin/docker' with working directory '/home/runner/work/...'. Argument list too long
with

      - name: Terragrunt Plan
        id: plan
        if: github.event_name == 'pull_request'
        run: terragrunt run-all plan -no-color --terragrunt-non-interactive
        continue-on-error: true

      - name: Post Plan
        uses: robburger/[email protected]
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          EXPAND_SUMMARY_DETAILS: 'true' # Override global environment variable; expand details just for this step
        with:
          commenter_type: plan
          commenter_input: ${{ format('{0}{1}', steps.plan.outputs.stdout, steps.plan.outputs.stderr) }}
          commenter_exitcode: ${{ steps.plan.outputs.exitcode }}

I was able to work around it by truncating the plan to 65535 characters before sending it to terraform-pr-commenter, but what is the maximum string length we can send to terraform-pr-commenter as I feel that is where the issue is? The terraform-pr-commenter code should properly truncate the string down to 65300 characters

  if [[ $EXIT_CODE -eq 0 || $EXIT_CODE -eq 2 ]]; then
    CLEAN_PLAN=$(echo "$INPUT" | sed -r '/^(An execution plan has been generated and is shown below.|Terraform used the selected providers to generate the following execution|No changes. Infrastructure is up-to-date.|No changes. Your infrastructure matches the configuration.|Note: Objects have changed outside of Terraform)$/,$!d') # Strip refresh section
    CLEAN_PLAN=$(echo "$CLEAN_PLAN" | sed -r '/Plan: /q') # Ignore everything after plan summary
    CLEAN_PLAN=${CLEAN_PLAN::65300} # GitHub has a 65535-char comment limit - truncate plan, leaving space for comment wrapper
    CLEAN_PLAN=$(echo "$CLEAN_PLAN" | sed -r 's/^([[:blank:]]*)([-+~])/\2\1/g') # Move any diff characters to start of line
    if [[ $COLOURISE == 'true' ]]; then
      CLEAN_PLAN=$(echo "$CLEAN_PLAN" | sed -r 's/^~/!/g') # Replace ~ with ! to colourise the diff in GitHub comments
    fi

although it would be nice to merge pull request #25 to give an indication that the plan was truncated/referenced elsewhere.

@neefrehman
Copy link

@jsimoni how did you truncate the plan before sending it to the action? I've just tried a couple of different ways but am just getting an empty details block

@jsimoni
Copy link
Author

jsimoni commented May 10, 2022

@neefrehman

          plan=$(cat <<'EOF'
          ${{ format('{0}{1}', steps.plan.outputs.stdout, steps.plan.outputs.stderr) }}
          EOF
          )
          echo "PLAN<<EOF" >> $GITHUB_ENV
          echo "${plan:0:65536}" >> $GITHUB_ENV
          echo "EOF" >> $GITHUB_ENV

and then read the value as:

          commenter_input: ${{ env.PLAN }}

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

No branches or pull requests

2 participants