Skip to content

Fix requesting urls containing parameters with parameters dict#2929

Merged
EnricoMi merged 5 commits intomainfrom
pagination-per-page
Oct 27, 2024
Merged

Fix requesting urls containing parameters with parameters dict#2929
EnricoMi merged 5 commits intomainfrom
pagination-per-page

Conversation

@EnricoMi
Copy link
Copy Markdown
Collaborator

Requesting an url that contains parameters (query part of the url) did not support giving a parameters dict:

Requester.requestJson(verb, "https://api.github.com/?per_page=10", {"per_page": 20})

Now, parameters given in the URL have precedence over the dict.

Iterating over reversed PaginatedList is affected by this.

Fixes #1136.

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.74%. Comparing base (e4106e0) to head (ae187c7).
Report is 1 commits behind head on main.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2929   +/-   ##
=======================================
  Coverage   96.74%   96.74%           
=======================================
  Files         147      147           
  Lines       14978    14984    +6     
=======================================
+ Hits        14491    14497    +6     
  Misses        487      487           

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

Copy link
Copy Markdown
Collaborator

@JLLeitschuh JLLeitschuh left a comment

Choose a reason for hiding this comment

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

Why allow duplicate request parameters at all, why not throw an exception?

If we're doing this internally, this seems like a bug?

@EnricoMi
Copy link
Copy Markdown
Collaborator Author

EnricoMi commented Apr 5, 2024

You are right, calling this method this way does not make much sense. But the code path that ends up in this situation is complex. Other code paths might suffer from the same issue, and it is not trivial to identify those.

It is expected that the values of the parameters are identical, so this is the right thing to do in that situation. I could throw an exception when parameter values contradict. But then this becomes a breaking change for some people where this just behaved incorrectly.

@Felixoid
Copy link
Copy Markdown
Contributor

Hello. Is there a chance we can have it merged?

@EnricoMi
Copy link
Copy Markdown
Collaborator Author

@JLLeitschuh you are right, now add_parameters_to_url gives precedence to the given parameters and overwrites params that exist in the url. The code path that produced the conflict now removes all params from parameters that are contained in the url, giving precedence in that particular situation only (which is the right thing to do there).

@EnricoMi EnricoMi enabled auto-merge October 27, 2024 17:26
@EnricoMi EnricoMi disabled auto-merge October 27, 2024 17:26
@EnricoMi EnricoMi enabled auto-merge October 27, 2024 17:27
@EnricoMi EnricoMi disabled auto-merge October 27, 2024 17:28
@EnricoMi EnricoMi merged commit e1d67ad into main Oct 27, 2024
@EnricoMi EnricoMi deleted the pagination-per-page branch October 27, 2024 17:28
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.

Paginated list reversed only gives the first page of results backwards

4 participants