-
Notifications
You must be signed in to change notification settings - Fork 98
Fix API v2.2 compatibility when opening a channel #6642
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
Conversation
📝 Walkthrough📝 Walkthrough📝 Walkthrough📝 WalkthroughWalkthroughThe changes in this pull request focus on the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
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.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
hoprd/rest-api/src/channels.rs (1)
257-257
: Update struct documentation to clarify field usageThe struct documentation should be updated to clarify:
- The relationship between
destination
andpeer_address
fields- That
peer_address
is provided for API v2.2 compatibilityAdd the following documentation above the struct:
#[derive(Debug, Clone, Deserialize, utoipa::ToSchema)] #[serde(rename_all = "camelCase")] #[schema(example = json!({ "amount": "10", "destination": "0xa8194d36e322592d4c707b70dbe96121f5c74c64" }))] +/// Request body for opening a channel. +/// +/// For compatibility with API v2.2, this struct accepts either: +/// - `destination`: The preferred way to specify the counterparty using PeerOrAddress +/// - `peer_address`: Legacy way to specify the counterparty using Address (API v2.2) pub(crate) struct OpenChannelBodyRequest {
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (1)
hoprd/rest-api/src/channels.rs
(2 hunks)
🔇 Additional comments (2)
hoprd/rest-api/src/channels.rs (2)
311-312
: LGTM! Implementation correctly handles API v2.2 compatibility
The changes properly handle both the new destination
field and the legacy peer_address
field, maintaining backward compatibility with API v2.2 while supporting the new PeerOrAddress
type.
Line range hint 257-312
: Verify API documentation and test coverage
Since this change affects the API contract, we should verify:
- API documentation is updated
- Test coverage exists for both new and legacy field usage
✅ Verification successful
API contract changes are properly documented and handled
The verification shows that:
- The
peer_address
field is properly documented in the OpenAPI schema throughutoipa
annotations - The code handles both
destination
andpeer_address
fields in a backward-compatible way - The API documentation in the route handler correctly describes the request body and possible responses
- The changes are consistent across the codebase with no outdated references
The implementation maintains backward compatibility while introducing the new field, and all documentation is up-to-date.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Check for API documentation files
echo "Checking for API documentation files..."
fd -e md -e yaml -e json "api|swagger|openapi"
# Check for test files
echo "Checking for related test files..."
fd -e rs "test.*channel"
# Check for usage of peer_address in tests
echo "Checking for peer_address usage in tests..."
rg -l "peer_address.*test" -g "*.rs"
Length of output: 622
Script:
#!/bin/bash
# Let's search for test files and peer_address usage more broadly
echo "Searching for channel-related test files..."
rg "mod test" -A 5 -g "*channel*.rs"
echo "Searching for peer_address usage..."
rg "peer_address" -B 2 -A 2 -g "*.rs"
# Check for API documentation in the specific REST API module
echo "Checking REST API documentation..."
rg "#\[utoipa::path" -A 10 -g "*channels.rs"
# Look for OpenChannelBodyRequest usage
echo "Checking OpenChannelBodyRequest usage..."
rg "OpenChannelBodyRequest" -g "*.rs"
Length of output: 14160
Opening a channel requires an
Address
aspeer_address
.When introducing the
PeerOrAddress
, thepeer_address
field was replaced bydestination
which allows bothPeerId
andAddress
to be used, but this is a breaking change.To avoid breaking changes, both previous and new field where set to be accepted, but a typo has been done: instead of accepting an
Address
it was set to accept aPeerId
.