You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@pekko.apache.org by GitBox <gi...@apache.org> on 2026/08/30 10:48:25 UTC
[GH] (pekko-grpc/malformed-response-headers): Workflow run "Scalafmt" is working again!
The GitHub Actions job "Scalafmt" on pekko-grpc.git/malformed-response-headers has succeeded.
Run started by GitHub user pjfanning (triggered by pjfanning).
Head commit for run:
d872912bbb00af3fb3fbc03549fa13980d4e526a / PJ Fanning <pj...@users.noreply.github.com>
Report malformed response headers as a gRPC status
Motivation:
Two spots in the pekko-http client turned a malformed response from the peer
into a raw JVM exception rather than a `StatusRuntimeException`, so a caller
matching on gRPC status saw something it could not handle.
`Status.fromCodeValue(statusCode.toInt)` threw `NumberFormatException` for a
server sending `grpc-status: abc`. Building the response metadata
base64-decodes every `-bin` header, so a malformed one threw
`IllegalArgumentException` - and `mapToStatusException` builds that metadata for
every error response, so an invalid binary header replaced the error actually
being reported with an exception about itself.
Both are reachable from any peer. The netty backend rejects these at the
transport layer, so this was pekko-http only.
Modification:
- A non-numeric `grpc-status` is reported as `INTERNAL`, quoting the offending
value. `parseResponseStatus` already matches on `Some("0")`, so such a
response was on the failure path regardless; it now fails with a status.
- Metadata construction falls back to empty metadata if a header cannot be
represented, so the status and message still reach the caller.
Result:
A broken or hostile peer produces a `StatusRuntimeException` like any other
failure, instead of an exception the caller is not expecting.
Tests:
- 2 cases in `PekkoHttpClientUtilsSpec`: a non-numeric `grpc-status`, and a
malformed `-bin` header alongside a real error that must still be reported
- Confirmed both guards bite: restoring `toInt` fails the first, removing the
metadata fallback fails the second
- sbt "runtime/testOnly ...PekkoHttpClientUtilsSpec" - 8 passed
- sbt "runtime/mimaReportBinaryIssues" - passed
- sbt scalafmtAll scalafmtSbt - applied
- sbt "runtime/test" - not run locally, left to CI
Note: `HeaderMetadataImpl.getBinary` and `asList` still throw on a malformed
binary header when a user calls them directly on a successful response. That is
left as is - an explicit accessor call is a different contract from the error
path, where the exception displaces an unrelated failure.
Co-Authored-By: Claude Opus 5 (1M context) <no...@anthropic.com>
Report URL: https://github.com/apache/pekko-grpc/actions/runs/33307355882
With regards,
GitHub Actions via GitBox
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org