Skip to content

feat: unmarshal grpc-status-details-bin trailer into error details#5711

Open
yordis wants to merge 1 commit intografana:masterfrom
yordis:yordis/grpc-error-details
Open

feat: unmarshal grpc-status-details-bin trailer into error details#5711
yordis wants to merge 1 commit intografana:masterfrom
yordis:yordis/grpc-error-details

Conversation

@yordis
Copy link

@yordis yordis commented Mar 4, 2026

What?

Read the grpc-status-details-bin trailer from gRPC error responses and expose its structured details in response.error.details in k6 test scripts.

Also fixes marshaling of standard Google protobuf types in error responses by using Resolver: nil instead of the per-connection user-defined type registry.

Why?

gRPC servers use the grpc-status-details-bin trailer as the standard mechanism to attach rich structured error information — things like ErrorInfo (reason, domain, metadata), BadRequest field violations, RetryInfo, etc. Previously k6 ignored this trailer entirely, always returning an empty details array even when the server sent structured errors.

Two issues were preventing this from working:

  1. The trailer was never read — response.error.details was always empty regardless of what the server sent.
  2. Even if the trailer had been read, the error was marshaled using Resolver: c.types, which only knows about user-defined protobuf types loaded via client.load(). Standard Google types like google.rpc.ErrorInfo are not in that registry, so they would marshal to empty objects. Using Resolver: nil falls back to the global protobuf registry which resolves them correctly.

Checklist

  • I have performed a self-review of my code.
  • I have commented on my code, particularly in hard-to-understand areas.
  • I have added tests for my changes.
  • I have run linter and tests locally (make check) and all pass.

Checklist: Documentation (only for k6 maintainers and if relevant)

Please do not merge this PR until the following items are filled out.

  • I have added the correct milestone and labels to the PR.
  • I have updated the release notes: link
  • I have updated or added an issue to the k6-documentation: grafana/k6-docs#NUMBER if applicable
  • I have updated or added an issue to the TypeScript definitions: grafana/k6-DefinitelyTyped#NUMBER if applicable

Related PR(s)/Issue(s)

@yordis yordis requested a review from a team as a code owner March 4, 2026 23:29
@yordis yordis requested review from ankur22 and oleiade and removed request for a team March 4, 2026 23:29
@cla-assistant
Copy link

cla-assistant bot commented Mar 4, 2026

CLA assistant check
All committers have signed the CLA.

@cla-assistant
Copy link

cla-assistant bot commented Mar 4, 2026

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@yordis yordis force-pushed the yordis/grpc-error-details branch from 2013833 to 7d7423e Compare March 4, 2026 23:34
@yordis yordis temporarily deployed to azure-trusted-signing March 5, 2026 13:09 — with GitHub Actions Inactive
Mark google.golang.org/genproto/googleapis/rpc as a direct dependency
since grpcext/conn.go directly imports the rpc/status package.
@yordis yordis force-pushed the yordis/grpc-error-details branch from 52ea233 to 00021c0 Compare March 7, 2026 04:49
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.

1 participant