Skip to content
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

DEPRECATE in 3.0 Add backwards compatible API to 2.1.x #6600

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

Teebor-Choka
Copy link
Contributor

This reverts commit b70b4a9.

@Teebor-Choka Teebor-Choka added this to the 3.0.0 milestone Nov 5, 2024
@Teebor-Choka Teebor-Choka requested review from jeandemeusy and a team November 5, 2024 17:28
@Teebor-Choka Teebor-Choka self-assigned this Nov 5, 2024
Copy link
Contributor

coderabbitai bot commented Nov 5, 2024

📝 Walkthrough

Walkthrough

The pull request introduces significant changes to the REST API request structures in three files: alias.rs, channels.rs, and messages.rs. The primary modification is the transformation of destination fields from optional to mandatory PeerOrAddress types. Additionally, peer_id and peer_address fields have been removed from these request structs. These changes simplify the request handling logic by enforcing the requirement of a destination and removing alternative ways of specifying destinations.

Changes

File Changes
hoprd/rest-api/src/alias.rs - AliasDestinationBodyRequest struct modified
- destination changed from Option<PeerOrAddress> to PeerOrAddress
- Removed peer_id field
hoprd/rest-api/src/channels.rs - OpenChannelBodyRequest struct modified
- destination changed from Option<PeerOrAddress> to PeerOrAddress
- Removed peer_address field
hoprd/rest-api/src/messages.rs - SendMessageBodyRequest struct modified
- destination changed from Option<PeerOrAddress> to PeerOrAddress
- Removed peer_id field

Sequence Diagram

sequenceDiagram
    participant Client
    participant RestAPI
    participant HoprNode

    Client->>RestAPI: Send request with mandatory destination
    RestAPI->>HoprNode: Process request with validated destination
    HoprNode-->>RestAPI: Perform requested operation
    RestAPI-->>Client: Return response
Loading

Possibly related PRs

Suggested labels

bug

Suggested reviewers

  • NumberFour8

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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added dependencies Pull requests that update a dependency file crate:hoprd-api labels Nov 5, 2024
@Teebor-Choka Teebor-Choka changed the title "DEPRECATE in 3.0 Add backwards compatible API to 2.1.x" DEPRECATE in 3.0 Add backwards compatible API to 2.1.x Nov 5, 2024
@github-actions github-actions bot removed the dependencies Pull requests that update a dependency file label Nov 18, 2024
@Teebor-Choka Teebor-Choka marked this pull request as ready for review January 16, 2025 19:23
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ed0973c and b783df6.

📒 Files selected for processing (3)
  • hoprd/rest-api/src/alias.rs (2 hunks)
  • hoprd/rest-api/src/channels.rs (3 hunks)
  • hoprd/rest-api/src/messages.rs (5 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: hoprd / docker
  • GitHub Check: hopli / docker
  • GitHub Check: Docs / Rust docs
  • GitHub Check: tests-smoke-websocket
  • GitHub Check: tests-unit-nightly
  • GitHub Check: tests-unit
  • GitHub Check: tests-smart-contracts
  • GitHub Check: Linter
🔇 Additional comments (9)
hoprd/rest-api/src/alias.rs (2)

105-105: LGTM! Code is now more straightforward.

The simplified error handling through direct use of args.destination improves code readability while maintaining proper error handling.


39-41: LGTM! Verify API deprecation notice is documented.

The change to make destination mandatory and remove the redundant peer_id field simplifies the API. This is a good change that reduces complexity and potential errors.

Let's verify the API deprecation notice is properly documented:

✅ Verification successful

API deprecation notice is properly documented

All alias endpoints are consistently marked with deprecation notices indicating removal in v3.0.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if the API deprecation notice is consistently documented
# Test: Search for deprecation notices in API documentation
rg -A 2 "deprecated.*v3\.0" hoprd/rest-api/src/alias.rs

Length of output: 662

hoprd/rest-api/src/channels.rs (3)

183-183: LGTM! Improved error handling.

The use of and_then instead of map provides better error handling in the async context.


306-306: LGTM! Consistent with API simplification pattern.

The simplified error handling through direct use of open_req.destination maintains consistency with changes across the codebase.


252-254: LGTM! Verify API deprecation notice is documented.

The change to make destination mandatory and remove the redundant peer_address field aligns with the API simplification across the codebase.

Let's verify the API deprecation notice is properly documented:

hoprd/rest-api/src/messages.rs (4)

149-149: LGTM! Consistent error handling improvement.

The simplified error handling through direct use of args.destination maintains consistency with changes across the codebase.


362-362: LGTM! Consistent with websocket handling.

The simplified error handling through direct use of msg.destination maintains consistency in the websocket message handling.


731-731: LGTM! Test updated to match API changes.

The test has been properly updated to reflect the non-optional destination field.


758-758: LGTM! Test updated to match API changes.

The test has been properly updated to reflect the non-optional destination field.

Comment on lines +69 to +71
#[serde_as(as = "DisplayFromStr")]
#[schema(value_type = String)]
peer_id: Option<hopr_lib::PeerId>,
destination: PeerOrAddress,
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Breaking changes need documentation

The changes to SendMessageBodyRequest struct are breaking changes that need to be properly documented:

  • Removing the Option wrapper from destination field makes it mandatory
  • Removing the peer_id field affects existing API consumers

Please add:

  • Deprecation notices in the API documentation
  • Version upgrade notes in README.md
  • Migration guide for API consumers
🔗 Analysis chain

LGTM! Verify API deprecation notice is documented.

The change to make destination mandatory and remove the redundant peer_id field completes the consistent API simplification across all files.

Let's verify the API deprecation notice is properly documented:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if the API deprecation notice is consistently documented
# Test: Search for deprecation notices in API documentation
rg -A 2 "deprecated.*v3\.0" hoprd/rest-api/src/messages.rs

Length of output: 60


Script:

#!/bin/bash
# Search for any deprecation notices or version annotations
rg -i "(deprecated|breaking|version|v3\.0)" hoprd/rest-api/src/messages.rs

# Check for API documentation comments
rg "^///|^//!" hoprd/rest-api/src/messages.rs

# Look for README or documentation files in rest-api directory
fd -e md -e txt . hoprd/rest-api/

Length of output: 1874


Script:

#!/bin/bash
# Check README for version information and breaking changes
cat hoprd/rest-api/README.md

# Look for version-related changes in git history
git log -n 5 --oneline hoprd/rest-api/src/messages.rs

Length of output: 33

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant