-
Notifications
You must be signed in to change notification settings - Fork 169
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
fix: [3] fix the error handling of getCommitSha #2362
fix: [3] fix the error handling of getCommitSha #2362
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small suggestion, otherwise LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you read another scm component?
For example, getCommitSha
in scm-gitlab checks response by checkResponseError. And this function set response.statusCode
to error.code
and also set response.body.message
to error.message
. Therefore the error object from scm-gitlab does not have status
member and it is not guaranteed that error.message
always has Branch not found
in this case.
I think you should make the interfaces of errors in scm component common by using boom.notFound
.
Co-authored-by: Mitsuru Takigahira <[email protected]>
plugins/events/create.js
Outdated
}) | ||
.catch(err => { | ||
if (err.status === 404) { | ||
throw boom.notFound(err); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you use the following code, you may be able to handle errors other than 404 with boom.
throw boom.boomify(err, {statusCode: err.status})
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thx. I fixed it.
Co-authored-by: Tiffany K <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Context
If we run a job in a pipeline whose corresponding SCM branch has been deleted, 500 error is thrown.
It is appropriate to throw 404 error in this case so we want to change that way.
Objective
/event
endpoint throws when we run a job in a pipeline whose corresponding SCM branch has been deleted. We set error status as 404.Context
We change the format of the error returned by.getCommitSha
in this PR so we change the error handling ofgetCommitSha
accordinglyObjective
We change the error handling ofgetCommitSha
.We change a test to follow this PR.We add a test in case we run a pipeline with the corresponding SCM branch deleted.We eliminated unnecessary variable assignments in test code for refactoring.Reference
screwdriver-cd/scm-gitlab#36
screwdriver-cd/scm-bitbucket#75
License
I confirm that this contribution is made under a BSD license and that I have the authority necessary to make this contribution on behalf of its copyright owner.