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

Argument list too long when logs encounter large output #1733

Closed
JamesIves opened this issue Mar 6, 2022 · 14 comments
Closed

Argument list too long when logs encounter large output #1733

JamesIves opened this issue Mar 6, 2022 · 14 comments
Assignees
Labels
bug Something isn't working

Comments

@JamesIves
Copy link

JamesIves commented Mar 6, 2022

Describe the bug

Multiple GitHub-provided actions are failing in their post-run steps due to an Argument list too long error.

To Reproduce

  1. Initiate the following workflow provided below from a user of my action. This workflow will fetch data from an API and save it as a JSON file so subsequent steps can do something with it. The action is not saving it as an environment variable, just a json file through Nodes fs.writeFile function.
name: Refresh Feed
on:
  workflow_dispatch:
jobs:
  refresh-feed:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout 🛎️
        uses: actions/checkout@v3
  
      - name: Fetch API Data 📦
        uses: JamesIves/fetch-api-data-action@releases/v2
        with:
          endpoint: https://api.scryfall.com/catalog/card-names
          configuration: '{ "method": "GET" }'
          save-location: assets
          save-name: test
          set-output: false
  1. You will get the following runner-related error. The same will occur if set-output is true in the fetch-api-data step as that makes the action save it as an environment variable: An error occurred trying to start process '/home/runner/runners/2.288.1/externals/node16/bin/node' with working directory '/home/runner/work/project/project'. Argument list too long.

Having looked at this briefly I suspect this is occurring as there's some degree of logging that occurs behind the scenes that are causing the argument list to overflow. If you toggle ACTIONS_STEP_DEBUG to true in the secrets menu you see this. The data parsed is large but I'm not really sure why this would be a problem.

Expected behavior

I am not really sure. If this is indeed the runner causing this due to logging I would expect there to be some form of fail-safe to prevent it from crashing.

Runner Version and Platform

  • ubuntu-latest

What's not working?

An error occurred trying to start process '/home/runner/runners/2.288.1/externals/node16/bin/node' with working directory '/home/runner/work/project/project'. Argument list too long.

Job Log Output

##[debug]Evaluating condition for step: 'Post Checkout 🛎️'
##[debug]Evaluating: always()
##[debug]Evaluating always:
##[debug]=> true
##[debug]Result: true
##[debug]Starting: Post Checkout 🛎️
##[debug]Loading inputs
##[debug]Evaluating: github.repository
##[debug]Evaluating Index:
##[debug]..Evaluating github:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'repository'
##[debug]=> 'JamesIves/reddit-viewer'
##[debug]Result: 'JamesIves/reddit-viewer'
##[debug]Evaluating: github.token
##[debug]Evaluating Index:
##[debug]..Evaluating github:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'token'
##[debug]=> '***'
##[debug]Result: '***'
##[debug]Loading env
Post job cleanup.
Error: An error occurred trying to start process '/home/runner/runners/[2](https://github.com/JamesIves/reddit-viewer/runs/5440253729?check_suite_focus=true#step:8:2).288.1/externals/node16/bin/node' with working directory '/home/runner/work/reddit-viewer/reddit-viewer'. Argument list too long
##[debug]System.ComponentModel.Win[3](https://github.com/JamesIves/reddit-viewer/runs/5440253729?check_suite_focus=true#step:8:3)2Exception (7): An error occurred trying to start process '/home/runner/runners/2.288.1/externals/node1[6](https://github.com/JamesIves/reddit-viewer/runs/5440253729?check_suite_focus=true#step:8:6)/bin/node' with working directory '/home/runner/work/reddit-viewer/reddit-viewer'. Argument list too long
##[debug]   at System.Diagnostics.Process.ForkAndExecProcess(ProcessStartInfo startInfo, String resolvedFilename, String[] argv, String[] envp, String cwd, Boolean setCredentials, UInt[32](https://github.com/JamesIves/reddit-viewer/runs/5440253729?check_suite_focus=true#step:8:32) userId, UInt32 groupId, UInt32[] groups, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean usesTerminal, Boolean throwOnNoExec)
##[debug]   at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
##[debug]   at System.Diagnostics.Process.Start()
##[debug]   at GitHub.Runner.Sdk.ProcessInvoker.ExecuteAsync(String workingDirectory, String fileName, String arguments, IDictionary`2 environment, Boolean requireExitCodeZero, Encoding outputEncoding, Boolean killProcessOnCancel, Channel`1 redirectStandardIn, Boolean inheritConsoleHandler, Boolean keepStandardInOpen, Boolean highPriorityProcess, CancellationToken cancellationToken)
##[debug]   at GitHub.Runner.Common.ProcessInvokerWrapper.ExecuteAsync(String workingDirectory, String fileName, String arguments, IDictionary`2 environment, Boolean requireExitCodeZero, Encoding outputEncoding, Boolean killProcessOnCancel, Channel`1 redirectStandardIn, Boolean inheritConsoleHandler, Boolean keepStandardInOpen, Boolean highPriorityProcess, CancellationToken cancellationToken)
##[debug]   at GitHub.Runner.Worker.Handlers.DefaultStepHost.ExecuteAsync(String workingDirectory, String fileName, String arguments, IDictionary`2 environment, Boolean requireExitCodeZero, Encoding outputEncoding, Boolean killProcessOnCancel, Boolean inheritConsoleHandler, CancellationToken cancellationToken)
##[debug]   at GitHub.Runner.Worker.Handlers.NodeScriptActionHandler.RunAsync(ActionRunStage stage)
##[debug]   at GitHub.Runner.Worker.ActionRunner.RunAsync()
##[debug]   at GitHub.Runner.Worker.StepsRunner.RunStepAsync(IStep step, CancellationToken jobCancellationToken)
##[debug]Finishing: Post Checkout 🛎️
@ruvceskistefan
Copy link
Contributor

Hi @JamesIves,
Thanks for reporting this issue! We will try to reproduce this issue and we will get back to you as soon as we have more information 😊

@ruvceskistefan ruvceskistefan self-assigned this Mar 7, 2022
@ruvceskistefan
Copy link
Contributor

Hi @JamesIves,
I tried to reproduce the reported problem, but I didn't succeed, your workflow works for me (see this).
However, I discovered the cause of the problem: during the cleanup, you download too many files and therefore receive such an error message from the OS. I am also sending a link in which the error you received is explained in more detail.
Since this is not a runner problem, I will close this issue. Feel free to reopen it if you have more questions and doubts.

@JamesIves
Copy link
Author

JamesIves commented Mar 7, 2022

I am somewhat confused about how I can run the exact same workflow in a different project and get different results. I read up on the error so I'm somewhat familiar with it but I don't really know how this is causing it?

Could the size of the contents of the repo be the problem? And if so is there a hard upper limit?

@ruvceskistefan
Copy link
Contributor

I further researched and concluded that this is not a runner bug, so I'll leave this issue closed for now. Please take a look at this issue, it is about a similar/same bug as the one you reported.

@jketcham
Copy link

In case it's helpful to anyone else that runs into this, I ran into this error with post-run steps, and it was because I had an environment variable set in $GITHUB_ENV that was too large (in my case a diff for kubernetes changes). Removing that env variable fixed the issue for me.

@jsimoni
Copy link

jsimoni commented Apr 12, 2022

I am also getting the Argument list too long error when trying to work with a larger (~ 7k characters) terraform plan output between multiple steps in my workflow.

@beyarkay
Copy link

Why was this closed? I'm having lot's of trouble trying to upload longer text streams

@umutkacar
Copy link

The issue is still present on v6.4.0

Run actions/github-script@v6.4.0
Error: An error occurred trying to start process '/runner/externals/node16/bin/node' with working directory '/runner/_work/repo-name/repo-name'. Argument list too long

@denist-huma
Copy link

denist-huma commented Jul 4, 2023

I got the same one today

Post Run actions/checkout@v3
Post job cleanup.
Error: An error occurred trying to start process '/home/runner/runners/2.305.0/externals/node16/bin/node' with working directory '/home/runner/work/huma-rpm-server/huma-rpm-server'. Argument list too long

@AngellusMortis
Copy link

Definitely still valid. We got the issue trying to store the git diff in an environment variable so only one job in the workflow needs a fetch-depth: 0.

@jketcham
Copy link

The best way to work around this is to store large outputs in a file instead of in an env var.

@PennyQ
Copy link

PennyQ commented Nov 24, 2023

Still no fix? We got the same issue with a very long Terraform plan output.

@raveheart1
Copy link

I found this stack overflow article where a user suggests truncating the tfplan result if the plan is too long.

add these to your workflow:

  - name: truncate terraform plan result
    run: |
      plan=$(cat <<'EOF'
      ${{ format('{0}{1}', steps.plan.outputs.stdout, steps.plan.outputs.stderr) }}
      EOF
      )
      echo "${plan}" | grep -v 'Refreshing state' >> $GITHUB_ENV
      echo "EOF" >> $GITHUB_ENV

  - name: create comment from plan result
    uses: actions/github-script@0.9.0
    if: github.event_name == 'pull_request'
    with:
      github-token: ${{ secrets.GITHUB_TOKEN }}
      script: |
        const output = `#### Terraform Initialization ⚙️\`${{ steps.init.outcome }}\`
        #### Terraform Plan 📖\`${{ steps.plan.outcome }}\`
        
        <details><summary>Show Plan</summary>
        
        \`\`\`\n
        ${ process.env.PLAN }
        \`\`\`
        
        </details>
        
        *Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`, Working Directory: \`${{ inputs.TF_WORK_DIR }}\`, Workflow: \`${{ github.workflow }}\`*`;

        github.issues.createComment({
          issue_number: context.issue.number,
          owner: context.repo.owner,
          repo: context.repo.repo,
          body: output
        })```

@tmlye
Copy link

tmlye commented Oct 30, 2024

My solution is to run the terraform show inside the comment step:

      - name: Plan
        id: plan
        working-directory: ${{ inputs.working_directory }}
        run: terraform plan -out tf.plan

      - name: Comment Plan
        uses: actions/github-script@v7
        continue-on-error: true
        with:
          script: |
            const fs = require('fs');
            const { execSync } = require('child_process');

            // Get the terraform plan output
            const planOutput = execSync('terraform show -no-color tf.plan', {
              cwd: '${{ inputs.working_directory }}'
            }).toString();

            const {data: comments} = await github.rest.issues.listComments({
              owner: context.repo.owner,
              repo: context.repo.repo,
              issue_number: context.payload.number,
            })
            const botComment = comments.find(comment => comment.user.id === 41898282 && comment.body.includes("${{ github.workflow }}"))

            if (!botComment) {
              github.rest.issues.createComment({
                issue_number: context.issue.number,
                owner: context.repo.owner,
                repo: context.repo.repo,
                body: `Terraform Plan for ${{ github.workflow }}:\n\`\`\`${planOutput}\`\`\``
              })
            } else {
              github.rest.issues.updateComment({
                owner: context.repo.owner,
                repo: context.repo.repo,
                comment_id: botComment.id,
                body: `Terraform Plan for ${{ github.workflow }}:\n\`\`\`${planOutput}\`\`\``
              })
            }

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