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

ERROR 422 (Invalid request. For 'properties/body', nil is not a string.) #1014

Closed
jcurlier opened this issue Jun 14, 2023 · 11 comments
Closed

Comments

@jcurlier
Copy link

Version: 15.11.0

If I release my nodeJS project twice, the second time it fails:

> @aura/content-service@2.223.0 release
> npx release-it

🚀 Let's release @aura/content-service (currently at 2.223.0)

Empty changelog

? Select increment (next version): patch (2.223.1)

Changeset:
 M package-lock.json
 M package.json

? Commit (Release 2.223.1)? Yes

? Tag (v2.223.1)? Yes
? Push? Yes

? Create a release on GitHub (Release 2.223.1)? Yes
ERROR 422 (Invalid request.

For 'properties/body', nil is not a string.)

The second release doesn't have any git changes, usually I use such a release to force a restart of the app and a refresh of the cache.

@christophemorio
Copy link

christophemorio commented Jun 14, 2023

I'm having the same issue, here a workaround by using release of May 2nd
https://github.com/release-it/release-it/releases/tag/15.10.3

        run: |
          npx release-it@15.10.3 --ci

@christophemorio
Copy link

After enable debug https://github.com/release-it/release-it/blob/main/README.md#troubleshooting--debugging, I spot a diff in body value.

But did not check by version sticking on octokit-rest upgraded dependency https://github.com/octokit/rest.js

15.10.3 ok

! octokit repos.createRelease "v2.8.3" (v2.8.3)
RELEASE-IT:GITHUB 523: {
  owner: 'Foo',
  repo: 'bar',
  tag_name: 'v2.8.3',
  name: 'v2.8.3',
  body: undefined,
  draft: false,
  prerelease: false,
  generate_release_notes: false
}
request {
  method: 'POST',
  baseUrl: 'https://api.github.com',
  headers: {
    accept: 'application/vnd.github.v3+json',
    'user-agent': 'release-it/15.10.3 octokit-rest.js/19.0.7 octokit-core.js/4.2.1 Node.js/17.9.1 (linux; x64)'
  },
  mediaType: { format: '', previews: [] },
  request: {
    timeout: 0,
    fetch: [AsyncFunction: fetch],
    hook: [Function: bound bound register]
  },
  url: '/repos/{owner}/{repo}/releases',
  owner: 'Foo',
  repo: 'bar',
  tag_name: 'v2.8.3',
  name: 'v2.8.3',
  draft: false,
  prerelease: false,
  generate_release_notes: false
}
POST /repos/Foo/bar/releases - 201 in 704ms

15.11.0 (latest) failed

! octokit repos.createRelease "v2.8.3" (v2.8.3)
RELEASE-IT:GITHUB 548: {
  owner: 'Foo',
  repo: 'bar',
  tag_name: 'v2.8.3',
  name: 'v2.8.3',
  body: null,
  draft: false,
  prerelease: false,
  generate_release_notes: false
}
request {
  method: 'POST',
  baseUrl: 'https://api.github.com',
  headers: {
    accept: 'application/vnd.github.v3+json',
    'user-agent': 'release-it/15.11.0 octokit-rest.js/19.0.11 octokit-core.js/4.2.1 Node.js/17.9.1 (linux; x64)'
  },
  mediaType: { format: '', previews: [] },
  request: {
    timeout: 0,
    fetch: [AsyncFunction: fetch],
    hook: [Function: bound bound register]
  },
  url: '/repos/{owner}/{repo}/releases',
  owner: 'Foo',
  repo: 'bar',
  tag_name: 'v2.8.3',
  name: 'v2.8.3',
  body: null,
  draft: false,
  prerelease: false,
  generate_release_notes: false
}
POST /repos/Foo/bar/releases - 422 in 256ms

@webpro
Copy link
Collaborator

webpro commented Jul 9, 2023

Sorry I'm late to the party, but is this still an issue? I've done a few updates of dependencies in the meantime.

@jcurlier
Copy link
Author

Still happening for me with 16.1.0

@aavargasp
Copy link

aavargasp commented Jul 12, 2023

Sorry I'm late to the party, but is this still an issue? I've done a few updates of dependencies in the meantime.

A little context

I realized that Gitlab returns 422 on the API for POST /projects/:id/releases when one or more of the required fields are missing. So I validated my theory trying the API directly then the question is why on **** is data missing?

Then after the 342 time reading the .md files for this, the next line got me thinking
image

So comparing 2 executions with the debug flag I finally found that the data missing is the tag info that must be on the release

My problem

Config git push default .release-it.json

"git": {
    "requireCleanWorkingDir": true,
    "commitMessage": "release v${version}"
  },

Detail log on my gitlab ci jo with default git push
default_git_push

Config git push modified .release-it.json

"git": {
    "requireCleanWorkingDir": true,
    "commitMessage": "release v${version}",
    "pushArgs": "-o ci.skip"
  },

Detail log on my gitlab ci jo with modifiedgit push (Missing tag!)
altered_git_push

About my solution

The problem was that I needed to add a pushArg to the final git push before the gitlab release and because of that my argument ovewrites one that is set by default

But the issue is that I assumed that if I needed to add more pushArgs to the git push it wouldn't affect the default push or append my args to the default ones (that I didn't know existed)

Added the default --follow-tags and my -o ci.skip to the pushArgs

"git": {
    "requireCleanWorkingDir": true,
    "commitMessage": "release v${version}",
    "pushArgs": "--follow-tags -o ci.skip"
  },

Working log with both args !
working_git_push

Now my release is created correctly because it has the missing tag data
Successfully released 0.0.2-beta.7

PS:

  • Sorry for the long post but I think this is really an error that should be fixed in a new version, so I wanted to explain in detail about this.
  • Because any new pushArgs should append to the unknown original one

@ShaunaGordon
Copy link

I'm still getting this on 16.1.5, as well, but oddly enough, aavargasp's solution no longer works for me (it had worked a few months ago, but no longer).

@seanpoulter
Copy link

Sorry I'm late to the party, but is this still an issue?

Yes. We just saw this on https://github.com/webdriverio-community/wdio-electron-service/actions/runs/8211712054/job/22461024964 using release-it@17.1.1. We were testing the pre-release GitHub Workflow and trying to increment the pre-release from 6.3.1-next.0 to 6.3.1-next.1 with no changes.

Let me know if you'd welcome a PR.

At first glance it looks like we'd want to remove null from the body on line 215. Can anyone help walk me through the downstream impact of that?

getOctokitReleaseOptions(options = {}) {
const { owner, project: repo } = this.getContext('repo');
const { releaseName, draft = false, preRelease = false, autoGenerate = false } = this.options;
const { tagName } = this.config.getContext();
const { version, releaseNotes, isUpdate } = this.getContext();
const { isPreRelease } = parseVersion(version);
const name = format(releaseName, this.config.getContext());
const body = autoGenerate ? (isUpdate ? null : '') : truncateBody(releaseNotes);

Since I'm not familiar with the code my proposal would be to:

  • Modify the nock to return 422 Unprocessable Entity if body is null
  • Make sure we have a failing test. I can try to reproduce my use case.
  • Prevent the body from being null

sourishkrout added a commit to stateful/runmejs that referenced this issue May 3, 2024
@webpro
Copy link
Collaborator

webpro commented May 8, 2024

Feel free to open a PR! I welcome PRs for sure and I'm happy to review. A draft PR is fine and I'm sure we'll sort it out.

goosewobbler added a commit to webdriverio-community/wdio-electron-service that referenced this issue Jul 23, 2024
kodai3 added a commit to kodai3/ubie-icons-native that referenced this issue Sep 5, 2024
kodai3 added a commit to kodai3/ubie-icons-native that referenced this issue Sep 5, 2024
due to issue release-it/release-it#1014

Signed-off-by: kodai3 <k3dai.su3@gmail.com>
igreenwood pushed a commit to ubie-oss/ubie-icons-native that referenced this issue Sep 5, 2024
due to issue release-it/release-it#1014

Signed-off-by: kodai3 <k3dai.su3@gmail.com>
@webpro
Copy link
Collaborator

webpro commented Sep 11, 2024

Going to close this one. If there's any remaining issues left, your best bet is a PR we can discuss. But new issues are fine too.

@webpro webpro closed this as completed Sep 11, 2024
@tedteng
Copy link

tedteng commented Dec 10, 2024

The issue still exists.

97 packages are looking for funding
  run `npm fund` for details
Creating Relase with tag v0.124.0
🚀 Let's release xxxx (0.123.0...0.124.0)
Empty changelog
- Git tag
✔ Git tag
- Git push
✔ Git push
- GitHub create release
✖ GitHub create release
ERROR 4[22](https://github.xxx/org/repo/actions/runs/9799094/job/4049413#step:5:23) (Invalid request.

For 'properties/body', nil is not a string. - https://docs.github.com/enterprise-server@3.12/rest/releases/releases#create-a-release)
Error: Process completed with exit code 1.

Github action

run: |
  npm install -g release-it
  next_ver="v$(release-it minor --release-version)"
  echo "Creating Release with tag $next_ver"
  release-it minor --ci

@webpro
Copy link
Collaborator

webpro commented Dec 10, 2024

your best bet is a PR we can discuss. But new issues are fine too.

A pull request works best, because that allows to understand the issue best and verify it's resolved properly in the environment the bug surfaced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants