-
Notifications
You must be signed in to change notification settings - Fork 391
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
Correctly initialise gRPCurl text area #340
base: master
Are you sure you want to change the base?
Correctly initialise gRPCurl text area #340
Conversation
FYI @dragonsinth |
f017e56
to
80b753f
Compare
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.
Was able to replicate the issue and verify that the fix works
80b753f
to
26ad7c7
Compare
@TilGP anything else needs for this to be merged? |
Apparently a review from someone with write access, which I am not. (I'm not affiliated with fullstorydev either). I just reviewed it with the hope, that it will bring some attention from the maintainers to this PR. |
@TilGP got it, I wrongly assumed that you were. Thanks for confirming the fix though. FYI @dragonsinth @jhump |
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. Though I also do not have write access to this repo 😂. (I left FullStory a couple of years ago.)
@dragonsinth, @gpassini, could one of you two take a look?
I'm not sure this is the best fix. I think the underlying problem is that |
@@ -154,9 +154,6 @@ window.initGRPCForm = function(services, svcDescs, mtdDescs, invokeURI, metadata | |||
// set raw request text | |||
updateJSONRequest(requestObj); | |||
|
|||
// init grpcCurl text | |||
updateCurlCommand(requestObj); | |||
|
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.
this part actually seems fine since updateJSONRequest
calls this internally
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.
@dragonsinth can you clarify please. The call to updateCurlCommand
is not required here, since updateJSONRequest
will do that. So removing this call actually fixes 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.
@dragonsinth anything else to address in this PR?
|
@gerektoolhy this is still a problem ^^ The issue is that the JSON string we shove into |
@gerektoolhy I pushed a commit onto your branch to try to address.. but I'll need you to retest with my changes and make sure they are good. |
It does fix the issue. However, this now works in a different way than before. The
So the reason the initial implementation used pretty printing was because the premise is that people will want to read the payload of the The |
Some quick thoughts... it seems to me in most cases the single-line input for a command line is a lot more portable? If you want to edit the request, you can edit it via the UI or |
@dragonsinth I guess it can be argued both ways which format is more usable. From my personal perspective, my use case is that I generate a Trying to think of another alternative... What about specifying a command line argument which would configure the formatting of the
I am up for implement this. The default could be one-line format, and this could be changed to pretty-print using the param. |
I am on your side with this, I would much prefer a human-readable format, while others may prefer a compact format. |
Description
#241 introduced feature where a
grpcurl
command would be rendered. Thegrpcurl
could then be copied and run in terminal repeatedly.Issue
After some use, I have noticed a small bug where on initial page load, the
grpcurl
would contain an incorrectly serialized payload[Object object]
. Expectation is that the payload should contain a valid JSON data. At a minimum this has to be an empty JSON object{}
, or anything that has been entered either from the first tab, or manually in the Request box.Root cause
The issue is introduced by line https://github.com/fullstorydev/grpcui/blob/master/internal/resources/webform/webform.js#L158 which calls, which calls
updateCurlCommand(requestObj);
. The problem with this line is thatrequestObj
is not a string parameter. This object ends up being concatenated to a string, and gets translated toObject object
.To trace this issue down I have instrumented updateCurlCommand() function and logged out how many times it was called and the stack trace along with it. It turned out that on page load this function was called twice. Surprisingly, the first call contained the correct JSON value, but the second not.
The first call was made from updateJsonRequest, which converted request object to
string
and passed that toupdateCurlCommand
.Fix
It turns out, that the second call to
updateCurlCommand
is not needed, and thus can be removed.After fix the
grpcurl
textbox correctly contains a valid JSON as data parameter: