Skip to content

feature: Include gRPC status details in error log messages#148

Merged
rustatian merged 3 commits into
masterfrom
fix/grpc-log-error-details
Jun 2, 2026
Merged

feature: Include gRPC status details in error log messages#148
rustatian merged 3 commits into
masterfrom
fix/grpc-log-error-details

Conversation

@rustatian

@rustatian rustatian commented Jun 2, 2026

Copy link
Copy Markdown
Member

The gRPC unary interceptor logged failed calls with only the raw error string, dropping the structured google.rpc.Status details that explain the failure. The error log now includes a details field rendering each status detail compactly (type + one-line value) — e.g. google.rpc.BadRequest: field_violations:{field:"email" description:"is required"}.

closes roadrunner-server/roadrunner#1897

Summary by CodeRabbit

  • Tests

    • Added comprehensive unit tests covering extraction and rendering of status details, including cases that skip non-google.rpc details and mixed-detail scenarios.
  • Chores

    • Enhanced error logging to include structured information, timing metrics, and rendered protobuf status details when present.

The unary interceptor logged failed calls with only the raw error string, dropping the structured google.rpc.Status details (BadRequest, ErrorInfo, etc.) that explain the failure. Add a details field that renders every status detail compactly (type + one-line value) via a small statusDetails helper covered by unit tests.

Ref: roadrunner-server/roadrunner#1897
Copilot AI review requested due to automatic review settings June 2, 2026 17:45
@coderabbitai

coderabbitai Bot commented Jun 2, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a statusDetails helper that formats only google.rpc.* protobuf details from grpc/status errors and updates the gRPC interceptor to include those rendered details in structured error logs; tests exercise empty, non-status, single, multiple, non-google.rpc, and mixed-detail scenarios.

Changes

gRPC error detail logging

Layer / File(s) Summary
statusDetails helper, imports, and formatting
server.go
Adds strings, proto, and prototext imports and implements statusDetails which filters status.Details() to google.rpc.* protobuf messages and formats them as compact one-line strings.
Interceptor error logging with rendered details
server.go
Replaces the static log argument list with a structured args slice (error, method, start, elapsed) and appends details when statusDetails returns entries.
statusDetails unit tests (expanded)
server_test.go
Adds tests for: no details, non-status error, single google.rpc.BadRequest, multiple google.rpc details (BadRequest + ErrorInfo), skipping a non-google.rpc detail (wrapperspb.StringValue), and mixed details where only google.rpc entries are kept.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

"I nibble logs and polish trails,
details tidy in styled little tails,
BadRequest, ErrorInfo — shown with care,
wrappers skipped, only google.rpc there,
a rabbit's hop makes errors fair. 🐇"

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The description addresses the problem and solution but is missing critical checklist items and incomplete reason/changelog references. Complete the PR checklist section and add issue reference in the 'Reason for This PR' section; verify CHANGELOG.md updates are included.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The code changes meet the primary objective [#1897] of logging google.rpc.* status details by filtering and rendering them in error logs.
Out of Scope Changes check ✅ Passed All changes are tightly scoped to the linked issue: adding statusDetails helper, updating error logging, and adding comprehensive test coverage.
Title check ✅ Passed The PR title accurately and concisely describes the main change: adding gRPC status details to error log messages. It directly reflects the core functionality added in both server.go and server_test.go.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/grpc-log-error-details

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@rustatian rustatian self-assigned this Jun 2, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances the gRPC unary server interceptor’s error logging by preserving and emitting structured google.rpc.Status detail messages (e.g., google.rpc.BadRequest field violations) alongside the primary error, improving debuggability of failed RPCs.

Changes:

  • Add a statusDetails(*status.Status) []string helper to render gRPC status Details() into compact log-friendly strings.
  • Extend interceptor error logging to include a details field when status details are present.
  • Introduce unit tests covering no-details, single-detail, and multiple-detail formatting scenarios.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
server.go Adds statusDetails and includes its output in interceptor error logs under a details field.
server_test.go Adds unit tests validating statusDetails behavior for empty, single, and multiple details.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread server.go Outdated
Comment thread server_test.go
Comment thread server_test.go
@codecov

codecov Bot commented Jun 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.66667% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.38%. Comparing base (c65181c) to head (0dcacf8).
⚠️ Report is 7 commits behind head on master.

Files with missing lines Patch % Lines
server.go 86.66% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #148      +/-   ##
==========================================
+ Coverage   77.56%   78.38%   +0.81%     
==========================================
  Files           7        7              
  Lines         468      495      +27     
==========================================
+ Hits          363      388      +25     
- Misses         79       80       +1     
- Partials       26       27       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@server.go`:
- Around line 135-142: The loop that serializes decoded Any details (variables:
details, out, d, m) should be restricted to only the well-known google.rpc
error-detail types; update the body that currently checks d.(proto.Message) to
instead check m.ProtoReflect().Descriptor().FullName() against an allowlist of
the standard types (e.g., google.rpc.BadRequest, google.rpc.DebugInfo,
google.rpc.ErrorInfo, google.rpc.LocalizedMessage, google.rpc.QuotaFailure,
google.rpc.RetryInfo, etc.), and only call prototext.MarshalOptions{}.Format(m)
for those allowed names; for any other message types append a safe placeholder
like "<redacted>" or just the message full name (e.g., fmt.Sprintf("%s:
<redacted>", fullName)) to out. Ensure you preserve the existing variables
(details, out, m) and only change the conditional/serialization logic in the
loop.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b686f81c-f7af-4c46-949c-8e62545badfc

📥 Commits

Reviewing files that changed from the base of the PR and between ad41b2d and 9a9fe20.

📒 Files selected for processing (2)
  • server.go
  • server_test.go

Comment thread server.go
rustatian added 2 commits June 2, 2026 21:17
A handler can attach an arbitrarily large custom detail via Any; serializing it into the error log on every failed call is a needless cost. Log only the well-known google.rpc.* error details (BadRequest, ErrorInfo, ...), which carry the useful diagnostics, and skip anything else.

Addresses CodeRabbit review on #148. Ref: roadrunner-server/roadrunner#1897
Replace the FullName-prefix check with a type switch over the errdetails types, so skipped (potentially large) details aren't touched by reflection at all.

Ref: roadrunner-server/roadrunner#1897
@rustatian rustatian changed the title Include gRPC status details in error log messages feature: Include gRPC status details in error log messages Jun 2, 2026
@rustatian rustatian merged commit 91e92d0 into master Jun 2, 2026
8 checks passed
@rustatian rustatian deleted the fix/grpc-log-error-details branch June 2, 2026 19:31
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.

[💡 FEATURE REQUEST]: Including grpc error details in log messages

2 participants