-
Notifications
You must be signed in to change notification settings - Fork 2.2k
rpcperms: enable rich gRPC status errors in middleware API #10458
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @hxrshxz, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly upgrades the RPC middleware API by enabling it to process and return "rich" gRPC status errors. Previously, the middleware could only handle errors as simple strings, losing valuable context like gRPC error codes. With this enhancement, the system can now serialize and deserialize full Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request enhances the RPC middleware API to support rich gRPC status errors, allowing middleware to inspect and modify errors with full details, including gRPC error codes. Previously, errors were just plain strings. The changes involve differentiating between plain errors and gRPC status errors during serialization for interception, and then correctly parsing them back when a replacement is provided by the middleware. New tests have been added to cover this new functionality. The implementation is solid, but there's a critical issue with a missing import alias that will prevent the code from compiling.
rpcperms/middleware_handler.go
Outdated
| "github.com/btcsuite/btcd/chaincfg" | ||
| "github.com/lightningnetwork/lnd/lnrpc" | ||
| "github.com/lightningnetwork/lnd/macaroons" | ||
| "google.golang.org/genproto/googleapis/rpc/status" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The package google.golang.org/genproto/googleapis/rpc/status is imported without an alias, but its types are later referenced with the spb prefix (e.g., spb.Status on line 637), which is not defined. This will cause a compilation error. Please add an alias to the import to resolve this.
| "google.golang.org/genproto/googleapis/rpc/status" | |
| spb "google.golang.org/genproto/googleapis/rpc/status" |
There was a problem hiding this comment.
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 RPC middleware API to support rich gRPC status errors with full error details including gRPC error codes, addressing issue #6729. Previously, errors intercepted by middleware were always serialized as plain strings, losing important error code information.
Key changes:
- Added support for serializing and deserializing gRPC status errors as
google.rpc.Statusproto messages - Introduced new constants to distinguish between plain error strings and rich gRPC status errors
- Updated error handling logic to preserve gRPC error codes throughout the middleware pipeline
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| rpcperms/middleware_handler.go | Implements the core functionality to serialize/deserialize gRPC status errors, adds constants for error type names, and introduces the parseErrorReplacement function to handle both plain and rich errors |
| rpcperms/middleware_handler_test.go | Adds comprehensive test coverage for the new error handling functionality, including tests for plain errors, gRPC status errors with different codes, and error parsing edge cases |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
rpcperms/middleware_handler.go
Outdated
| "github.com/btcsuite/btcd/chaincfg" | ||
| "github.com/lightningnetwork/lnd/lnrpc" | ||
| "github.com/lightningnetwork/lnd/macaroons" | ||
| "google.golang.org/genproto/googleapis/rpc/status" |
Copilot
AI
Dec 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a naming conflict with two imports both named "status". Line 15 imports "google.golang.org/genproto/googleapis/rpc/status" and line 17 imports "google.golang.org/grpc/status", but neither has an alias. This will cause a compilation error. Additionally, line 637 references spb.Status{} but there's no import with the alias "spb". The genproto import should be aliased (e.g., as "spb") to resolve both issues.
| "google.golang.org/genproto/googleapis/rpc/status" | |
| spb "google.golang.org/genproto/googleapis/rpc/status" |
552a311 to
43b78df
Compare
Change Description
Enable the RPC middleware API to return "rich" gRPC errors with full error details including gRPC error codes (fixes #6729).
Previously, errors intercepted by the RPC middleware were always serialized as plain error strings. This meant middleware could only see
Steps to Test
go test -v ./rpcperms/...Pull Request Checklist
Testing
Code Style and Documentation
[skip ci]not needed as tests are included.📝 Please see our Contribution Guidelines for further guidance.