Skip to content

[BUG]: Creating deployments fail with "Request body length does not match content-length header" on renamed repos #405

Open
@NiklasMerz

Description

@NiklasMerz

What happened?

I updated my very old octokit and nodejs version to the most recent ones and creating deployments now fails.

The repo got renamed and the action was using the old name.

Some code:

let options = {
  auto_merge: false,
  owner: 'myorga',
  repo: 'myproject',
  ref: 'develop',
  environment: 'testing'
}

async function createDeployment(options) {
    options.task = 'deploy';
    options.required_contexts = [];
    let result = await octokit.rest.repos.createDeployment(options)
    const id = result.data.id;
    console.log(id);
    fs.writeFileSync(process.env.HOME + '/deployment_action', id);
    
    console.log(result.status == 201 ? 'Done': 'Error');
    if(result.status != 201) {
        console.error(result);
        process.exit(1);
    }
}

Versions

octokit-rest.js/20.0.2
octokit-core.js/5.1.0
Node.js/18.19.0 (linux; x64)',

Relevant log output

/node_modules/@octokit/request/dist-node/index.js:156
    throw new import_request_error.RequestError(message, 500, {
          ^

RequestError [HttpError]: Request body length does not match content-length header
    at /node_modules/@octokit/request/dist-node/index.js:156:11
    at async createDeployment (/usr/bin/deployment.js:13:18) {
  status: 500,
  request: {
    method: 'POST',
    url: 'https://api.github.com/repos/pragmaticindustries/ukonn-wizard/deployments',
    headers: {
      accept: 'application/vnd.github.v3+json',
      'user-agent': 'octokit-rest.js/20.0.2 octokit-core.js/5.1.0 Node.js/18.19.0 (linux; x64)',
      authorization: 'token [REDACTED]',
      'content-type': 'application/json; charset=utf-8'
    },
    body: '{"auto_merge":false,"ref":"develop","environment":"testing","task":"deploy","required_contexts":[]}',
    request: { hook: [Function: bound bound register] }
  }
}

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

added
Status: TriageThis is being looked at and prioritized
Type: BugSomething isn't working as documented
on Jan 25, 2024
github-actions

github-actions commented on Jan 25, 2024

@github-actions
Contributor

👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

NiklasMerz

NiklasMerz commented on Jan 25, 2024

@NiklasMerz
Author

After finding this issue semantic-release/github#746 I realized we renamed the repo and the workflow used the old name. Strange error but this fixes it.

moved this from 🆕 Triage to ✅ Done in 🧰 Octokit Activeon Jan 25, 2024
wolfy1339

wolfy1339 commented on Jan 25, 2024

@wolfy1339
Member

Maybe this warrants a mention in the docs? Or maybe there is a fix that we can do on our side to avoid the error

changed the title [-][BUG]: Creating deployments fail with "Request body length does not match content-length header"[/-] [+][BUG]: Creating deployments fail with "Request body length does not match content-length header" on renamed repos[/+] on Jan 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: BugSomething isn't working as documented

    Type

    No type

    Projects

    Status

    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @NiklasMerz@wolfy1339@kfcampbell

        Issue actions

          [BUG]: Creating deployments fail with "Request body length does not match content-length header" on renamed repos · Issue #405 · octokit/rest.js