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

Cannot read property 'statusCode' of undefined #212

Closed
beselig opened this issue Jan 25, 2021 · 3 comments
Closed

Cannot read property 'statusCode' of undefined #212

beselig opened this issue Jan 25, 2021 · 3 comments

Comments

@beselig
Copy link

beselig commented Jan 25, 2021

Current behavior

During verification process, when facing SSL problems, the following Error occurs:

TypeError: Cannot read property 'statusCode' of undefined
    at module.exports (/builds/....../test-ci-semantic-release/node_modules/@semantic-release/gitlab/lib/verify.js:65:26)
    at processTicksAndRejections (node:internal/process/task_queues:94:5)
    at async verifyConditions (/builds/....../test-ci-semantic-release/node_modules/@semantic-release/gitlab/index.js:9:3)
    at async validator (/builds/....../test-ci-semantic-release/node_modules/semantic-release/lib/plugins/normalize.js:34:24)
    at async /builds/....../test-ci-semantic-release/node_modules/semantic-release/lib/plugins/pipeline.js:37:34
    at async Promise.all (index 0)
    at async next (/builds/....../test-ci-semantic-release/node_modules/p-reduce/index.js:16:18) {
  pluginName: '@semantic-release/gitlab'
}

Expected behavior

The Error handling in line 62 of verify.js is broken. It expects error.response to be always defined, which is not the case.

The catch block should not cause its own error, making the original error, which occured (i.e. due to our SSL issue), inaccessible.

Simple solution would be to just throw the error, when error.response is undefined. This is at least how we debugged this ourselves.

Environment

  • "@semantic-release/gitlab": "^6.0.8"
  • semantic-release configuration:
    "branches": ["master"],
    "plugins": [
        "@semantic-release/commit-analyzer",
        "@semantic-release/release-notes-generator",
        [
            "@semantic-release/gitlab",
            {
                "gitlabUrl": "https://gitlab.XYZ.net",
                "gitlabApiPathPrefix": "/api/v4"
            }
        ],
        "@semantic-release/npm",
        [
            "@semantic-release/git",
            {
                "assets": ["package.json"],
                "message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
            }
        ]
    ],
    "debug": true
}
  • CI logs:
TypeError: Cannot read property 'statusCode' of undefined
    at module.exports (/builds/....../test-ci-semantic-release/node_modules/@semantic-release/gitlab/lib/verify.js:65:26)
    at processTicksAndRejections (node:internal/process/task_queues:94:5)
    at async verifyConditions (/builds/....../test-ci-semantic-release/node_modules/@semantic-release/gitlab/index.js:9:3)
    at async validator (/builds/....../test-ci-semantic-release/node_modules/semantic-release/lib/plugins/normalize.js:34:24)
    at async /builds/....../test-ci-semantic-release/node_modules/semantic-release/lib/plugins/pipeline.js:37:34
    at async Promise.all (index 0)
    at async next (/builds/....../test-ci-semantic-release/node_modules/p-reduce/index.js:16:18) {
  pluginName: '@semantic-release/gitlab'
}
@nfriend
Copy link
Contributor

nfriend commented Jan 27, 2021

Thanks for this @beselig! I opened #214 with your solution:

Simple solution would be to just throw the error, when error.response is undefined.

@nfriend
Copy link
Contributor

nfriend commented Jan 27, 2021

@beselig #214 has been merged - would you mind upgrading @semantic-release/gitlab to version 6.0.9 or later and see if this solves the issue? 🙏

@beselig
Copy link
Author

beselig commented Jan 28, 2021

@nfriend Thanks for the fast fix!

We just tested the new version and it works as expected.

I'm closing the issue, as it is solved with #214

@beselig beselig closed this as completed Jan 28, 2021
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

2 participants