github
github copied to clipboard
Outdated package.json "repository" field fails when creating release
I’ve had this issue twice already, so posting here to share and potentially fix the issue in here, or maybe (most likely?) it’s an issue with the GitHub API.
If you rename a repository, and forget to update the repository field in package.json, this plugin fails when creating a release with the following error:
[9:38:17 AM] [semantic-release] › ℹ Start step "publish" of plugin "@semantic-release/github"
[9:38:32 AM] [semantic-release] › ✘ Failed step "publish" of plugin "@semantic-release/github"
[9:38:32 AM] [semantic-release] › ✘ An error occurred while running semantic-release: RequestError [HttpError]: fetch failed
at /home/runner/work/serverless-plugin-env-stage-config/serverless-plugin-env-stage-config/node_modules/.pnpm/@[email protected]/node_modules/@octokit/request/dist-node/index.js:136:11
at async requestWithGraphqlErrorHandling (/home/runner/work/serverless-plugin-env-stage-config/serverless-plugin-env-stage-config/node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@octokit/plugin-retry/dist-node/index.js:71:20)
at async Job.doExecute (/home/runner/work/serverless-plugin-env-stage-config/serverless-plugin-env-stage-config/node_modules/.pnpm/[email protected]/node_modules/bottleneck/light.js:405:18) {
status: 500,
request: {
method: 'POST',
url: 'https://api.github.com/repos/bizon/serverless-plugin-stage-config/releases',
headers: {
accept: 'application/vnd.github.v3+json',
'user-agent': '@semantic-release/github v9.0.4 octokit-core.js/5.0.0 Node.js/20.11.1 (linux; x64)',
authorization: 'token [REDACTED]',
'content-type': 'application/json; charset=utf-8'
},
body: '{"tag_name":"v1.3.7","target_commitish":"master","name":"v1.3.7","body":"## [1.3.7](https://github.com/bizon/serverless-plugin-stage-config/compare/v1.3.6...v1.3.7) (2024-03-29)\\n\\n\\n### Bug Fixes\\n\\n* re-release ([3a067ca](https://github.com/bizon/serverless-plugin-stage-config/commit/3a067ca38cc[60](https://github.com/bizon/serverless-plugin-env-stage-config/actions/runs/8479540859/job/23233712289#step:6:61)c8fa862cddc20a32b8673a79cd0))\\n\\n\\n\\n","prerelease":false}',
request: {
agent: undefined,
hook: [Function: bound bound register],
retryCount: 3,
retries: 3,
retryAfter: 16
}
},
pluginName: '@semantic-release/github'
}
The package was renamed from serverless-plugin-stage-config to serverless-plugin-env-stage-config. The redirections are still active, but POSTing a new release fails with a 500 error.
Maybe there could be an extra step in verify that checks if the repository field is valid?
I would love that, I ran into this problem several times myself and saw countless others run into it as well
Makes sense to do this really, we can resolve the owner and repo from the package.json repository.url and verify the check with the GitHub's get-a-repository endpoint, where we will only work with the "response status code" to validate.
But how would you suggest we handle feedback to user? Is a simple log alerting user to update the package.json repository.url field in the terminal good enough!? 🤔
But how would you suggest we handle feedback to user? Is a simple log alerting user to update the package.json
repository.urlfield in the terminal good enough!? 🤔
i think this would be a great step from where we are today. i expect that helping folks have an explanation for the failure would help fixing the problem be far more clear
i expect that helping folks have an explanation for the failure would help fixing the problem be far more clear
I agree with this, it'll make for a great DX.
:tada: This issue has been resolved in version 10.1.2 :tada:
The release is available on:
Your semantic-release bot :package::rocket: