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

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

Open
1 task done
NiklasMerz opened this issue Jan 25, 2024 · 3 comments
Labels
Type: Bug Something isn't working as documented

Comments

@NiklasMerz
Copy link

NiklasMerz commented Jan 25, 2024

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
@NiklasMerz NiklasMerz added Status: Triage This is being looked at and prioritized Type: Bug Something isn't working as documented labels Jan 25, 2024
Copy link
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
Copy link
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.

@NiklasMerz NiklasMerz closed this as not planned Won't fix, can't repro, duplicate, stale Jan 25, 2024
@wolfy1339
Copy link
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

@NiklasMerz NiklasMerz reopened this Jan 25, 2024
@NiklasMerz NiklasMerz 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 Jan 25, 2024
@kfcampbell kfcampbell removed the Status: Triage This is being looked at and prioritized label Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Something isn't working as documented
Projects
Archived in project
Development

No branches or pull requests

3 participants