-
Notifications
You must be signed in to change notification settings - Fork 150
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
[MM-350] Fix issue in create issue modal and attach issue modal #761
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 are a lot of other endpoints that don't return valid JSON in the error case. Should we update the webapp to not expect JSON if the status code indicates an error?
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.
@hanzei We were thinking of updating the plugin API response for each API where we are not returning anything in case we get any errors from the GitHub API.
For example: At this line, we can return an error something like
p.writeAPIError(w, &APIErrorResponse{Message: "Failed to search for issues", StatusCode: http.StatusInternalServerError})
and handle the error similarly at the webapp side.What are your thoughts on 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.
If
githubClient.Search.Issues
finds nothing that matches the search, does it return anerror
?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 we put an invalid organisation or an organisation we don't have access to, we get an error, and it gets rendered as shown in the screenshot below.
But it doesn't return any errors when we search for an issue with a random input term (empty or an organisation we have access to).
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.
We def want to avoid showing this
Unexpected end of JSON input
error in all casesThere 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 see the value in consistently returning a JSON payload for calls the webapp makes. Should this be addressed holistically as part of this PR?
I suggest we update the signature of API methods like
searchIssue
from(c *UserContext, w http.ResponseWriter, r *http.Request)
to(c *UserContext, r *http.Request) (any, int)
and let a wrapper handle deal with writing the returned payload and status code. That way we ensure that all of these endpoint return valid JSON.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.
@hanzei Should we create a new issue to update the structure of the APIs and merge this PR to resolve the issue mentioned in the description?
Also, there were two ways we were thinking of fixing the response of the API:
(c *UserContext, w http.ResponseWriter, r *http.Request)
to(c *UserContext, r *http.Request) (any, int)
as stated by you. We can also include a field oferror
with the data and the status code. In the wrapper, we can check for errors and data. If the error is returned, we can returnp.writeAPIError(w, &APIErrorResponse{Message: "ErrorMessage", StatusCode: statusCode})
and handle similarly on webapp and if there is no error we can return data or an empty list if data is also empty.p.writeAPIError(w, &APIErrorResponse{Message: "ErrorMessage", StatusCode: statusCode})
in case of error. We can avoid making a wrapper in this case.What are your thoughts on this? Please let me know if I missed something here.
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.
Either one sounds good to me. Which one is less complicated in your opinion @ayusht2810? Have you tried implemented one of them to see if it fits well?
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.
@mickmister We are thinking to proceed with the second method.
we can do this it in this PR or we can create a new PR and merge this so that the issue is fixed
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.
@Kshitij-Katiyar Sure separate PR sounds good 👍