]> git.kaiwu.me - haproxy.git/commitdiff
REGTESTS: protobuf: cover the gRPC message compression flag
authorFrederic Lecaille <flecaille@haproxy.com>
Thu, 19 Nov 2026 09:53:40 +0000 (10:53 +0100)
committerFrederic Lecaille <flecaille@haproxy.com>
Thu, 19 Nov 2026 09:57:16 +0000 (10:57 +0100)
Regression test for "BUG/MINOR: sample: do not parse compressed gRPC
messages in ungrpc".

Two bodies are added to the frontend which already walks a body of two
gRPC messages:

  - "01 00000005 0a03616161 00 00000002 1007" flags the first message
    compressed. Its payload must not be parsed, so x-g1 stays empty
    instead of reading "aaa". x-g2 must still find 7 in the second
    message, which checks the skip resumes on a message boundary.

  - "02 00000002 1007" sets an invalid flag, so the walk must stop and
    x-g2 must stay empty.

A failing expect aborts the script, so the second body is only observed
after the fix, not before it.

reg-tests/protobuf/grpc.vtc

index 095378c74ceae8870ace27244fdd706a7b08f42d..6595a2878cebca14cf7e065818ee24207a11264b 100644 (file)
@@ -232,3 +232,32 @@ client c3 -connect ${h1_fe3_sock} {
        expect resp.http.x-g2 == "7"
        expect resp.http.x-g3 == ""
 } -run
+
+# The first message is flagged compressed. HAProxy does not decompress, so
+# its payload must not be handed to the protobuf parser: "0a03616161" would
+# otherwise read as field 1 = "aaa", a value that only exists after
+# decompression. The converter skips it and reaches field 2 of the second,
+# uncompressed message.
+client c4 -connect ${h1_fe3_sock} {
+       txreq -req POST -url "/" -hdr "content-length: 17" \
+             -hdr "grpc-encoding: gzip" -nolen
+       sendhex "01 00000005 0a03616161 00 00000002 1007"
+       rxresp
+       expect resp.status == 200
+       expect resp.http.x-g1 == ""
+       expect resp.http.x-g2 == "7"
+       expect resp.http.x-g3 == ""
+} -run
+
+# The Compressed-Flag may only be 0 or 1. 02 makes the framing invalid, so
+# the walk stops instead of parsing the payload: field 2 = 7 must not be
+# reported.
+client c5 -connect ${h1_fe3_sock} {
+       txreq -req POST -url "/" -hdr "content-length: 7" -nolen
+       sendhex "02 00000002 1007"
+       rxresp
+       expect resp.status == 200
+       expect resp.http.x-g1 == ""
+       expect resp.http.x-g2 == ""
+       expect resp.http.x-g3 == ""
+} -run