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] Remove trailing slash from forwarded requests #159

Merged
merged 4 commits into from
Feb 13, 2025

Conversation

alyssadai
Copy link
Contributor

@alyssadai alyssadai commented Feb 12, 2025

Changes proposed in this pull request:

  • Refactor out logic for constructing request URLs to the target nodes
  • Do not append a trailing slash to the request URLs

Checklist

This section is for the PR reviewer

  • PR has an interpretable title with a prefix ([ENH], [FIX], [REF], [TST], [CI], [MNT], [INF], [MODEL], [DOC]) (see our Contributing Guidelines for more info)
  • PR has a label for the release changelog or skip-release (to be applied by maintainers only)
  • PR links to GitHub issue with mention Closes #XXXX
  • Tests pass
  • Checks pass

For new features:

  • Tests have been added

For bug fixes:

  • There is at least one test that would fail under the original bug conditions.

Summary by Sourcery

Remove trailing slash from URLs used to forward requests to Neurobagel nodes.

Bug Fixes:

  • Prevent incorrect URL formation when forwarding requests to target nodes, which caused request failures.

Tests:

  • Add tests to verify that request URLs are correctly formed without a trailing slash.

Summary by Sourcery

Remove trailing slashes from URLs used to forward requests to Neurobagel nodes.

Bug Fixes:

  • Prevent incorrect URL construction when forwarding requests to target nodes.

Tests:

  • Add tests to verify that request URLs are correctly formed without trailing slashes.

Copy link

sourcery-ai bot commented Feb 12, 2025

Reviewer's Guide by Sourcery

This pull request fixes a bug related to URL formation for forwarded requests by removing the trailing slash. The changes refactor the URL construction logic into a new function and update existing endpoint calls to use it. Additionally, tests have been added to ensure URLs are correctly formed without trailing slashes.

Sequence diagram for URL forwarding in API

sequenceDiagram
    participant C as Client
    participant G as get() Function
    participant B as build_node_request_urls()
    participant U as util.send_get_request()

    C->>G: Request API call with parameters
    G->>B: build_node_request_urls(node_urls, "query")
    B-->>G: Return list of node_request_urls
    loop For each node_request_url
        G->>U: send_get_request(node_request_url, params, token)
        U-->>G: Response
    end
    G-->>C: Aggregated response
Loading

File-Level Changes

Change Details Files
Refactored URL construction to eliminate redundant trailing slashes.
  • Introduced a new function to build request URLs for nodes without appending a trailing slash.
  • Updated endpoints (get, get_instances, get_pipeline_versions) to call the new URL construction function.
  • Simplified URL concatenation to ensure consistency across different node requests.
app/api/crud.py
Implemented tests to validate URL formatting.
  • Added a parameterized test to verify that the built node request URLs do not include a trailing slash.
tests/test_attribute_factory_routes.py

Assessment against linked issues

Issue Objective Addressed Explanation
#158 Remove trailing slash from request URLs when forwarding requests to Neurobagel nodes
#158 Ensure compatibility with the latest version of the n-API that no longer supports paths with trailing slashes

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@alyssadai alyssadai marked this pull request as ready for review February 12, 2025 21:54
@alyssadai alyssadai added pr-bug-fix Bug fix, will increment patch version when merged (0.0.+1) release Create a release when this PR is merged labels Feb 12, 2025
@alyssadai alyssadai requested a review from surchs February 12, 2025 21:54
Copy link

codecov bot commented Feb 12, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.41%. Comparing base (5263128) to head (81072d1).
Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #159      +/-   ##
==========================================
+ Coverage   97.37%   97.41%   +0.03%     
==========================================
  Files          23       23              
  Lines         724      735      +11     
==========================================
+ Hits          705      716      +11     
  Misses         19       19              

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

Copy link
Contributor

@surchs surchs left a comment

Choose a reason for hiding this comment

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

Thanks @alyssadai, looks good. One point to address on the test, but with that

🧑‍🍳

@alyssadai alyssadai merged commit bf6a22b into main Feb 13, 2025
9 checks passed
@alyssadai alyssadai deleted the fix-trailing-slash-bug branch February 13, 2025 03:42
Copy link
Contributor

🚀 PR was released in v0.4.5 🚀

@neurobagel-bot neurobagel-bot bot added the released This issue/pull request has been released. label Feb 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-bug-fix Bug fix, will increment patch version when merged (0.0.+1) release Create a release when this PR is merged released This issue/pull request has been released.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Forwarded n-API requests for variable instances still include trailing slash
2 participants