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

fix(grpc): import proto files relative to parent proto #1705

Merged
merged 3 commits into from
Apr 19, 2024
Merged

Conversation

ssddOnTop
Copy link
Member

@ssddOnTop ssddOnTop commented Apr 11, 2024

Summary:
example:

greetings_a.proto:

syntax = "proto3";

package greetings_a;
import "greetings_b.proto";

service Greeter {
  rpc SayHello (greetings_b.HelloRequest) returns (greetings_b.HelloReply) {}
}

greetings_b.proto:

syntax = "proto3";

package greetings_b;

message HelloRequest {
  string name = 1;
}

message HelloReply {
  string message = 1;
}

let greetings_a.proto be the main file which imports greetings_b.proto. Just importing greetings_b.proto throws an file not found error because it treats it as absolute path.

This pr fixes this issue by using path of parent file as relative/parent path.

Summary by CodeRabbit

  • Refactor
    • Updated import paths in multiple proto files to use relative paths for better modularity and maintenance.
    • Enhanced the ProtoReader with additional functionalities to improve path resolution and file handling.

Copy link
Contributor

coderabbitai bot commented Apr 11, 2024

Walkthrough

Walkthrough

The recent updates primarily focus on enhancing path handling in protocol buffer files and the ProtoReader class in a codebase. The modifications include transitioning from absolute to relative import paths in several proto files, and significant improvements in ProtoReader to support dynamic path resolution. These changes aim to improve modularity and ease of maintenance in handling protocol buffer file dependencies.

Changes

Files Change Summary
.../cycle.proto, .../duplicate.proto, .../nested0.proto, .../nested1.proto Updated import paths from absolute to relative.
src/proto_reader.rs Enhanced path handling with new methods and modifications in ProtoReader to support dynamic resolution of paths.

Recent Review Details

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 2a8c86e and 2c01bdc.
Files selected for processing (1)
  • src/proto_reader.rs (7 hunks)
Additional Context Used
Path-based Instructions (1)
src/proto_reader.rs (1)

Pattern **/*.rs: Programming Style Guidelines

  • When calling functions that do not need to modify values, pass references of those values.
  • When calling functions that need to modify values, pass ownership of the values, and ensure they are returned from the function.

IMPORTANT: This programming style may not be suitable for performance-sensitive components or hot code paths. In such cases, prioritize efficiency and optimization strategies to enhance performance.

Testing

  1. Write Tests: For every new feature or bugfix, ensure that you write appropriate tests.
    Structure your tests in the following way:

    use pretty_assertions::assert_eq;
    fn test_something_important() {
       let value = setup_something_using_a_function();
    
       let actual = perform_some_operation_on_the_value(value);
       let expected = ExpectedValue {foo: 1, bar: 2};
    
       assert_eq!(actual, expected);
    }
    • Setup the value using helper methods in tests.
    • Create an actual and an expected value.
    • Assert the two values in a new line.
    • Ensure there are only one assertions per test.
Additional comments not posted (3)
src/proto_reader.rs (3)

34-41: The modifications to the read method, including the addition of the parent_dir parameter to the read_proto call, correctly implement the handling of relative paths as intended by the PR.


50-56: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [53-63]

The addition of the parent_path parameter in the resolve_descriptors method and its use in dependency resolution are well-implemented and align with the PR's objectives to handle relative paths.


86-100: The changes to the read_proto method, including the handling of well-known Google proto files and the use of the resolve_path method for other files, are correctly implemented. However, consider adding a comment to clarify the handling of HTTP paths in the resolve_path method.

Consider adding a comment in the resolve_path method to clarify that HTTP paths are directly returned without modifications, which might not be immediately obvious to other developers.


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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 the type: fix Iterations on existing features or infrastructure. label Apr 11, 2024
Copy link

codecov bot commented Apr 11, 2024

Codecov Report

Attention: Patch coverage is 92.85714% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 86.91%. Comparing base (0f46776) to head (2c01bdc).

Files Patch % Lines
src/proto_reader.rs 92.85% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1705   +/-   ##
=======================================
  Coverage   86.90%   86.91%           
=======================================
  Files         155      155           
  Lines       15568    15588   +20     
=======================================
+ Hits        13530    13548   +18     
- Misses       2038     2040    +2     

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

Copy link

Action required: PR inactive for 2 days.
Status update or closure in 5 days.

@github-actions github-actions bot added the state: inactive No current action needed/possible; issue fixed, out of scope, or superseded. label Apr 13, 2024
Copy link

PR closed after 5 days of inactivity.

@github-actions github-actions bot closed this Apr 18, 2024
@ssddOnTop ssddOnTop reopened this Apr 18, 2024
@github-actions github-actions bot removed the state: inactive No current action needed/possible; issue fixed, out of scope, or superseded. label Apr 18, 2024
@meskill meskill changed the title fix(proto): imports fix(grpc): import proto files relative to parent proto Apr 18, 2024
@meskill
Copy link
Contributor

meskill commented Apr 18, 2024

@ssddOnTop could you please fix the conflicts?

@meskill meskill merged commit ed7bdc6 into main Apr 19, 2024
31 checks passed
@meskill meskill deleted the fix/proto-inputs branch April 19, 2024 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: fix Iterations on existing features or infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants