workflow-dispatch icon indicating copy to clipboard operation
workflow-dispatch copied to clipboard

Action fails with "Error: Request body length does not match content-length header"

Open relaxdiego opened this issue 1 year ago • 2 comments

This action was previously working for us but started failing randomly since about 3 weeks ago. I tried looking at its code but couldn't find anything to suggest what the cause might be. There is this issue in another project that experiences the same error but I didn't take time yet to dig deeper: https://github.com/semantic-release/github/issues/746. Hopefully that provides enough hints.

Sample error:

Run benc-uk/[email protected]
  with:
    repo: XXXXXXXXX/yyyyyyyyyyy
    workflow: zzzzzzzzz.yml
    ref: main
    token: ***
🏃 Workflow Dispatch Action v1.2.1
🔎 Found workflow, id: 58803020, name: XXXXXXXXXX path: .github/workflows/yyyyyyyy.yml
🚀 Calling GitHub API to dispatch workflow...
Error: Request body length does not match content-length header

relaxdiego avatar Jul 10 '24 21:07 relaxdiego

It seems like an issue with the API? Could you also try the latest version v1.2.4 ?

benc-uk avatar Aug 03 '24 09:08 benc-uk

Hey! I was also experiencing this since a recent version (I think the update that added node 20 support), up to the current version too (1.2.4)

For me, our organization name on GH had changed. What Github then does is it keeps redirecting the old name to the new name, but I guess the API gets confused since the name length changes, and the action fails as a result.

Solution

For me, the solution was to use the new (current) name of the organization/account where the workflow repo is located

Example

Before:

- uses: benc-uk/workflow-dispatch@v1
  with:
    workflow: workflow-name
    repo: longer-company-name/repo-name
    ref: develop
    token: ${{ secrets.PERSONAL_TOKEN }}
    inputs: '{ "foo": "bar" }'

Then, our organization GH account changed from longer-company-name to comp-name (i.e. the length of the organization name changed, I suspect this might be key), and the above error occured. To fix it, I had to use our new company name in the workflow:

- uses: benc-uk/workflow-dispatch@v1
  with:
    workflow: workflow-name
    repo: comp-name/repo-name
    ref: develop
    token: ${{ secrets.PERSONAL_TOKEN }}
    inputs: '{ "foo": "bar" }'

If I just browse to github.com/longer-company-name/repo-name GH automatically redirects me to github.com/comp-name/repo-name, but I guess the action/API does not do this everywhere.

If it's fixable within this action, even better, but you should honestly just keep the organization/account names up-to-date anyways 😅 I suspect this may also be why the issue occurs for other people :)

Also, thanks for the useful action :)

frankvollebregt avatar Sep 02 '24 12:09 frankvollebregt