Skip to content

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

@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

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

    Issue actions