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

Ensure client self hrefs don't end in '/' #373

Merged
merged 6 commits into from
Dec 12, 2022

Conversation

gadomski
Copy link
Member

@gadomski gadomski commented Dec 7, 2022

Related Issue(s):

Description:

Our url construction is a bit naïve -- we use basic string formatting, e.g.

url = f"{self.get_self_href()}/collections"

As raised in #369, this can lead to request urls containing double //, which breaks some APIs (e.g. out-of-the-box stac-fastapi). This PR does the simplest-possible fix by ensuring that a Client's self href doesn't end in a slash.

PR Checklist:

  • Code is formatted
  • Tests pass
  • Changes are added to the CHANGELOG

@codecov-commenter
Copy link

codecov-commenter commented Dec 12, 2022

Codecov Report

Base: 85.30% // Head: 85.31% // Increases project coverage by +0.01% 🎉

Coverage data is based on head (80d7363) compared to base (a7fdec1).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #373      +/-   ##
==========================================
+ Coverage   85.30%   85.31%   +0.01%     
==========================================
  Files          11       11              
  Lines         796      797       +1     
==========================================
+ Hits          679      680       +1     
  Misses        117      117              
Impacted Files Coverage Δ
pystac_client/client.py 85.00% <100.00%> (+0.15%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@gadomski gadomski added this to the 0.5.2 milestone Dec 12, 2022
Copy link
Collaborator

@pjhartzell pjhartzell left a comment

Choose a reason for hiding this comment

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

LGTM

@gadomski gadomski merged commit 7a90819 into main Dec 12, 2022
@gadomski gadomski deleted the issues/369-self-href-trailing-slash branch December 12, 2022 21:29
@m-mohr
Copy link

m-mohr commented Jan 16, 2023

@gadomski I don't think this is a good idea. We recently had a similar case in STAC Browser:

Not sure why this API implementation works this way, but removing the slash from the "self URL" was also my first instinct, but quickly I got complaints. So I think the right fix for this can only be to construct the URLs correctly when merging URI parts.

@gadomski gadomski self-assigned this Jan 17, 2023
@gadomski
Copy link
Member Author

Hm, it's a good point -- this PR makes the assumption that we know what's best w.r.t. trailing slashes on the root endpoint, but that's not always the case.

I'll cook up a more robust solution in a new PR.

gadomski added a commit that referenced this pull request Jan 17, 2023
gadomski added a commit that referenced this pull request Jan 18, 2023
gadomski added a commit that referenced this pull request Jan 18, 2023
gadomski added a commit that referenced this pull request Jan 19, 2023
@gadomski gadomski modified the milestones: 0.5.2, 0.6.0 Jan 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Do something when STAC endpoint url ends with "/"
5 participants