Skip to content

maximum commenter_input length? #32

@jsimoni

Description

@jsimoni

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions