-
Notifications
You must be signed in to change notification settings - Fork 122
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
showing all error when publishing fails #1327
showing all error when publishing fails #1327
Conversation
src/registry/routes/publish.ts
Outdated
@@ -65,20 +65,20 @@ export default function publish(repository: Repository) { | |||
res.status(200).json({ ok: true }); | |||
} catch (err: any) { | |||
if (err.code === 'not_allowed') { | |||
res.errorDetails = `Publish not allowed: ${err.msg}`; | |||
res.status(403).json({ error: err.msg }); | |||
res.errorDetails = `Publish not allowed: ${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.
I think the proposed solutions included more lines to transform the errormessage
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.
Hey Ricardo,
I should have mentioned it while raising the PR.
Anyways in the proposed solution
I was checking the error object
if it has msg
field or message
field, if none then I was JSON.stringify
ing the object and setting it everywhere
But it made sense to me, to just send the whole error object.
Let me know if you think otherwise or why should we not do this.
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.
Well I'm thinking that we probably shouldn't return a stack trace on a production environment API
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.
Makes sense.
I have made the changes that match the same as I had proposed in the issue.
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.
Do you think we should also include logging errors ?
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.
I think maybe we can base it on res.conf.local
to decide if we pass the whole thing or not
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.
Do you think, will it be better to use res.conf.debug
instead of local?
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.
There is no conf.debug property. Local should be fine.
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.
Cool, I have made the changes
Sending whole error log only when `err.msg` and `err.message` fields are not present in error object
LGTM |
Relates to #1326
Explain the details for making this change. What existing problem does the pull request solve?
This is to avoid empty error responses as mentioned in issue.
closes #1326
.