Skip to content

Commit c1cae43

Browse files
authored
tap: Fix the failure of protobuf to PCAP generation (#28180)
tap: Fix the protobuf to PCAP generation failure When run 'bazel run @envoy_api//tools:tap2pcap path_0.pb path_0.pcap': ... Traceback (most recent call last): File "..../tools/tap2pcap.runfiles/envoy_api/tools/tap2pcap.py", line 88, in <module> tap2pcap(sys.argv[1], sys.argv[2]) File "..../tools/tap2pcap.runfiles/envoy_api/tools/tap2pcap.py", line 53, in tap2pcap wrapper.ParseFromString(f.read()) ^^^^^^^^ File "<frozen codecs>", line 322, in decode UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb8 in position 1: invalid start byte ... The protobuf file is in binary format, opening this file in binary mode will help to generate the PCAP file successfully. Signed-off-by: Haiyue Wang <[email protected]>
1 parent d266941 commit c1cae43

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

api/tools/tap2pcap.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def tap2pcap(tap_path, pcap_path):
4949
with open(tap_path, 'r') as f:
5050
text_format.Merge(f.read(), wrapper)
5151
else:
52-
with open(tap_path, 'r') as f:
52+
with open(tap_path, 'rb') as f:
5353
wrapper.ParseFromString(f.read())
5454

5555
trace = wrapper.socket_buffered_trace

0 commit comments

Comments
 (0)