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

[pull] master from fullstorydev:master #14

Merged
merged 2 commits into from
Jan 14, 2024
Merged

Conversation

pull[bot]
Copy link

@pull pull bot commented Jan 14, 2024

See Commits and Changes for more details.


Created by pull[bot]

Can you help keep this open source service alive? 💖 Please sponsor : )

dependabot bot and others added 2 commits January 8, 2024 17:07
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.19.0 to
0.20.0.
<details>
<summary>Commits</summary>
<ul>
<li>See full diff in <a
href="https://github.com/golang/net/commits">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=golang.org/x/net&package-manager=go_modules&previous-version=0.19.0&new-version=0.20.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
## Problem Statement

When using gRPC UI, I came across a scenario where I did not want
default values emitted to the Response tab. While gRPCurl has an option
to enable/disable emit-defaults, gRPC UI does not since the call it
makes to gRPCurl hard-codes emit-defaults to true. Thus, there was an
inconsistency between these two closely related tools.

## Example Proto File

```Proto
service Greeter {
   rpc SayHello (HelloRequest) returns (HelloReply);
}

message HelloRequest {
   string name = 1;
}

message TwoNums {
   int32 abc = 1;
   int32 xyz = 2;
}

message HelloReply {
   oneof HelloReplies {
      TwoNums nums = 1;
      int32 num = 2;
   }
   string answer = 3;
}
```

## Sample Server Implementation - Written in Go


[server.txt](https://github.com/fullstorydev/grpcui/files/13245072/server.txt)

## gRPC UI Output

```JSON
{
  "nums": {
    "abc": 3,
    "xyz": 3
  },
  "answer": ""
}
```

## gRPCurl Output with `-emit-defaults=false`

```JSON
{
  "nums": {
    "abc": 3,
    "xyz": 3
  }
}
```

## Fix

- Added `emit-defaults` flag to the `cmd/grpcui.go` file.
- Set a global variable in `handlers.go` to accept value of
`emit-defaults` flag.
- The default value of this flag is `true`, to preserve existing
behavior

```bash
grpcui -h
...
-emit-defaults
        Emit default values for JSON-encoded responses. (default true)
...
```

## gRPC UI Output After Fix with `-emit-defaults=false`

```JSON
{
  "nums": {
    "abc": 3,
    "xyz": 3
  }
}
```

---------

Co-authored-by: = <[email protected]>
@pull pull bot added the ⤵️ pull label Jan 14, 2024
@pull pull bot merged commit 06f546d into kkpan11:master Jan 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant