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

showing all error when publishing fails #1327

Conversation

ashmeet-kandhari
Copy link
Contributor

Relates to #1326

Explain the details for making this change. What existing problem does the pull request solve?

  • Putting the whole error object in error response when publishing fails.
    This is to avoid empty error responses as mentioned in issue.

closes #1326 .

@@ -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}`;
Copy link
Collaborator

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

Copy link
Contributor Author

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.stringifying 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.

Copy link
Collaborator

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

Copy link
Contributor Author

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.

Copy link
Contributor Author

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 ?

Copy link
Collaborator

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

Copy link
Contributor Author

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?

Copy link
Collaborator

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.

Copy link
Contributor Author

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

ashmeet-kandhari and others added 2 commits March 16, 2023 11:57
Sending whole error log only when `err.msg` and `err.message` fields are not present in error object
@ricardo-devis-agullo
Copy link
Collaborator

LGTM

@ricardo-devis-agullo ricardo-devis-agullo merged commit 6854d2b into opencomponents:master Apr 25, 2023
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

Successfully merging this pull request may close these issues.

2 participants