(PUP-8008) Avoid double-encoding Forge API pagination URIs#6287
(PUP-8008) Avoid double-encoding Forge API pagination URIs#6287scotje wants to merge 2 commits intopuppetlabs:masterfrom
Conversation
|
Oops, looks like there are 2 sets of unit tests for the Forge code. I'll fix up the other tests. |
26ee9dc to
5c7139d
Compare
|
Waiting for CLA signature by @scotje @scotje - We require a Contributor License Agreement (CLA) for people who contribute to Puppet, but we have an easy click-through license with instructions, which is available at https://cla.puppet.com/ Note: if your contribution is trivial and you think it may be exempt from the CLA, please post a short reply to this comment with details. http://docs.puppet.com/community/trivial_patch_exemption.html |
| def fetch(input) | ||
| name = input.tr('/', '-') | ||
| uri = "/v3/releases?module=#{name}" | ||
| uri = "/v3/releases?module=#{name}&sort_by=version" |
There was a problem hiding this comment.
Out of curiosity, why did you add the sort by query param here? (could this go in the commit message?)
There was a problem hiding this comment.
I'll add some info to the commit message.
There was a problem hiding this comment.
Can you query directly by version number here?
There was a problem hiding this comment.
Yes but PMT currently collects all the available versions in case it needs them when resolving dependencies.
lib/puppet/forge.rb
Outdated
| uri = "/v3/releases?module=#{name}&sort_by=version" | ||
| if Puppet[:module_groups] | ||
| uri += "&module_groups=#{Puppet[:module_groups].gsub('+', ' ')}" | ||
| uri += "&module_groups=#{Puppet[:module_groups]}" |
There was a problem hiding this comment.
is there any downside to leaving these gsub's here in case something else is using this uri?
5c7139d to
6fb7f2d
Compare
|
Updated commit message for |
|
CLA signed by all contributors. |
…ersion If there is a problem traversing additional pages of results from the Forge, this at least will ensure that the latest versions of the requested modules are found and installable. This also enables a future optimization of only fetching the first page of results for each module and seeing if that is sufficient to resolve dependencies.
6fb7f2d to
86345b0
Compare
| @repository.make_http_request(*args) | ||
| def make_http_request(uri, *args) | ||
| # Change plus to space so it can be encoded properly | ||
| uri = uri.gsub('+', ' ') |
There was a problem hiding this comment.
Since this is called by download as well, I'm not sure that this is the safest location to make this change. I think it was intentional to make that mod inline before.
|
I think it would be good to look at a couple of things before making changes here:
|
In the actual module name? I don't think non-ASCII characters have ever been allowed in module names on the Forge. (See https://github.com/puppetlabs/puppet-forge-api/blob/master/app/validators.rb for the accepted regexes) But we can upload whatever we want to one of the non-public Forge instances for testing.
I'm guessing the pagination has probably been broken since then? It only manifests if the requested release isn't in the first page of results so it may have taken that long for the issue to surface. The previous commit to that: puppet/lib/puppet/forge/repository.rb Line 75 in 5ce0917 Uses You can see the issue pretty clearly if you adjust the debug logging the way I did in the PR without any of the other changes: Specifically, the first request for each page has
It's a public API that has been documented and recommended for ~4 years so it's hard to definitively answer that question. At the least there is |
|
I still think this change is worth making, but in typing out my last response I realized we can probably work around this to some extent by accepting a literal |
|
Closing this, opening a new fix targeted at 4.10.x first. |
This should resolve the issue with PMT following the pagination links returned by the Forge API.