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

template error when using --binary-file #284

Closed
wjackson opened this issue Jun 15, 2021 · 4 comments
Closed

template error when using --binary-file #284

wjackson opened this issue Jun 15, 2021 · 4 comments

Comments

@wjackson
Copy link

Proto file(s)
Anything with a bytes field. BytesValue for example.

Command line arguments / config
--binary-file

Describe the bug

Binary protobuf messages with bytes fields cause template errors like this:

template: call_template_data:2: unrecognized character in action: U+FFFD '�'

If the bytes happen to contain character sequences that look like template directives.

The problem template call seems to be here

To Reproduce

Here's a test that produces the error.

Expected behavior

Binary messages provided via --binary or --binary-file are not processed by template and work regardless of what byte patterns they happen to have.

Environment

  • OS: linux
  • ghz: 0.95.0
@bojand
Copy link
Owner

bojand commented Aug 2, 2021

Hmm I am a little confused by the steps to reproduce as it's using greeter.proto file.

if we have a service definition like:

syntax = "proto3";

package wrapped;

option go_package = "internal/wrapped";

import "google/protobuf/wrappers.proto";

service WrappedService {
  rpc GetBytesMessage (google.protobuf.BytesValue) returns (google.protobuf.BytesValue);
}

This works:

protoMsg := wrappers.BytesValue{Value: []byte("Hello World!")}
msg, err := proto.Marshal(&protoMsg)

report, err := Run(
	"wrapped.WrappedService.GetBytesMessage",
	WithProtoFile("../testdata/wrapped.proto", []string{"../testdata"}),
	WithBinaryData(msg),
	// ...
)

Similarly we can write the data to a file and use --binary-file option.

@bojand bojand closed this as completed Aug 2, 2021
@wjackson
Copy link
Author

wjackson commented Aug 5, 2021

As mentioned, the problem happens when the byte sequence, by bad luck, contains something that looks like a template directive. []byte("Hello World!") doesn't exercise the bug. The test I linked to does though.

bojand added a commit that referenced this issue Aug 6, 2021
do not attempt template actions with binary data. fixes #284
@bojand
Copy link
Owner

bojand commented Aug 6, 2021

Hello, sorry I misunderstood the issue... This should be fixed in v0.98.0. If there are more problems with this feel free to reopen or create a new issue.

@wjackson
Copy link
Author

wjackson commented Aug 6, 2021

Awesome! Thanks for taking the time to address this.

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

No branches or pull requests

2 participants