Skip to content

LocalReply: fix a bug of invalid json format in grpc-message#11621

Merged
htuch merged 1 commit into
envoyproxy:masterfrom
qiwzhang:fix-grpc-status
Jun 18, 2020
Merged

LocalReply: fix a bug of invalid json format in grpc-message#11621
htuch merged 1 commit into
envoyproxy:masterfrom
qiwzhang:fix-grpc-status

Conversation

@qiwzhang
Copy link
Copy Markdown
Contributor

Signed-off-by: Wayne Zhang qiwzhang@google.com

For grpc requests, error message will write to grpc-message header.
LocalReplyConfig::body_format still applies. If it is JSON format, grpc-message header value will be in json too.

But there is a bug when json format is used, it generates an invalid json format as:

grpc-message: '{"code":401,"message":"Jwt is missing"%0A'

It should be:

grpc-message: '{"code":401,"message":"Jwt is missing"}'

Risk Level: Low
Testing: integration test

Signed-off-by: Wayne Zhang <qiwzhang@google.com>
Copy link
Copy Markdown
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@htuch htuch merged commit 439a9f0 into envoyproxy:master Jun 18, 2020
yashwant121 pushed a commit to yashwant121/envoy that referenced this pull request Jun 24, 2020
For grpc requests, error message will write to grpc-message header.
LocalReplyConfig::body_format still applies. If it is JSON format, grpc-message header value will be in json too.

But there is a bug when json format is used, it generates an invalid json format as:

grpc-message: '{"code":401,"message":"Jwt is missing"%0A'
It should be:

grpc-message: '{"code":401,"message":"Jwt is missing"}'
Risk Level: Low
Testing: integration test

Signed-off-by: Wayne Zhang <qiwzhang@google.com>
Signed-off-by: yashwant121 <yadavyashwant36@gmail.com>
songhu pushed a commit to songhu/envoy that referenced this pull request Jun 25, 2020
For grpc requests, error message will write to grpc-message header.
LocalReplyConfig::body_format still applies. If it is JSON format, grpc-message header value will be in json too.

But there is a bug when json format is used, it generates an invalid json format as:

grpc-message: '{"code":401,"message":"Jwt is missing"%0A'
It should be:

grpc-message: '{"code":401,"message":"Jwt is missing"}'
Risk Level: Low
Testing: integration test

Signed-off-by: Wayne Zhang <qiwzhang@google.com>
yashwant121 pushed a commit to yashwant121/envoy that referenced this pull request Jul 24, 2020
For grpc requests, error message will write to grpc-message header.
LocalReplyConfig::body_format still applies. If it is JSON format, grpc-message header value will be in json too.

But there is a bug when json format is used, it generates an invalid json format as:

grpc-message: '{"code":401,"message":"Jwt is missing"%0A'
It should be:

grpc-message: '{"code":401,"message":"Jwt is missing"}'
Risk Level: Low
Testing: integration test

Signed-off-by: Wayne Zhang <qiwzhang@google.com>
Signed-off-by: yashwant121 <yadavyashwant36@gmail.com>
@yurykats
Copy link
Copy Markdown
Contributor

@qiwzhang The description here and the comment in the code mentioned JSON, yet the last character is stripped from body unconditionally. Was that intentional?

This is breaking some Envoy gRPC responses for me, when the body is not JSON and is actually a binary payload. This stripping corrupts the response if the binary payload happens to end with 0x0A.

@qiwzhang
Copy link
Copy Markdown
Contributor Author

qiwzhang commented Aug 2, 2021

Yes, we should check content_type to be JSON before trimming the last byte.

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.

3 participants