Issue #4904
closed
pulp-file_client might be encoding request URLs incorrectly
Status:
CLOSED - CURRENTRELEASE
Description
While working with the latest pulp-file_client ruby gem we observed issues with URL formatting:
From the client side:
PulpFileClient::ApiError: Error message: the server returns an error
HTTP status code: 404
Response headers: {"Server"=>"nginx/1.12.2", "Date"=>"Mon, 03 Jun 2019 19:40:07 GMT", "Content-Type"=>"text/html", "Content-Length"=>"77", "Connection"=>"keep-alive", "X-Frame-Options"=>"SAMEORIGIN"}
Response body: <h1>Not Found</h1><p>The requested resource was not found on this server.</p>
/home/vagrant/projects/katello/app/lib/pulp/v3/api.rb:29:in `remotes_file_file_delete'
/home/vagrant/projects/katello/app/services/katello/pulp3/repository/file.rb:40:in `delete_remote'
/home/vagrant/projects/katello/test/support/pulp3_support.rb:26:in `ensure_creatable'
/home/vagrant/projects/katello/test/services/katello/pulp3/file_unit_test.rb:13:in `setup'
/home/vagrant/projects/katello/test/support/vcr.rb:24:in `block in run'
/home/vagrant/projects/katello/test/support/vcr.rb:23:in `run'
And on the pulp3 server side:
gunicorn[2934]: pulp: django.request:WARNING: Not Found: /%2Fpulp%2Fapi%2Fv3%2Fremotes%2Ffile%2Ffile%2F0bbe78bc-eea8-4103-bc2f-eede6a1c8c7a%2F
Note the path is decoded as:
//pulp/api/v3/remotes/file/file/0bbe78bc-eea8-4103-bc2f-eede6a1c8c7a/
- Has duplicate Issue #4906: Cannot read remote using remotes_file_file_read method added
Forgot to mention this was discovered in pulp_file_client 3.0.0rc2.dev.1559507270
- Triaged changed from No to Yes
- Sprint set to Sprint 53
- Sprint changed from Sprint 53 to Sprint 54
Also observed in pulpcore_client 3.0.0rc2.dev.1559833395.
Here's an example of a debugger session:
[84, 93] in /home/vagrant/foreman/.vendor/ruby/2.5.0/gems/pulpcore_client-3.0.0rc2.dev.1559833395/lib/pulpcore_client/api_client.rb
84: # @option opts [Hash] :query_params Query parameters
85: # @option opts [Hash] :form_params Query parameters
86: # @option opts [Object] :body HTTP body (JSON/XML)
87: # @return [Typhoeus::Request] A Typhoeus Request
88: def build_request(http_method, path, opts = {})
=> 89: url = build_request_url(path)
90: http_method = http_method.to_sym.downcase
91:
92: header_params = @default_headers.merge(opts[:header_params] || {})
93: query_params = opts[:query_params] || {}
(byebug) path
"%2Fpulp%2Fapi%2Fv3%2Frepositories%2F9be3daf5-0831-4b84-ab54-9b1b5ceffe16%2F"
(byebug) s
[258, 267] in /home/vagrant/foreman/.vendor/ruby/2.5.0/gems/pulpcore_client-3.0.0rc2.dev.1559833395/lib/pulpcore_client/api_client.rb
258: filename.gsub(/.*[\/\\]/, '')
259: end
260:
261: def build_request_url(path)
262: # Add leading and trailing slashes to path
=> 263: path = "/#{path}".gsub(/\/+/, '/')
264: @config.base_url + path
265: end
266:
267: # Builds the HTTP request body
(byebug) path
"%2Fpulp%2Fapi%2Fv3%2Frepositories%2F9be3daf5-0831-4b84-ab54-9b1b5ceffe16%2F"
(byebug) n
[259, 268] in /home/vagrant/foreman/.vendor/ruby/2.5.0/gems/pulpcore_client-3.0.0rc2.dev.1559833395/lib/pulpcore_client/api_client.rb
259: end
260:
261: def build_request_url(path)
262: # Add leading and trailing slashes to path
263: path = "/#{path}".gsub(/\/+/, '/')
=> 264: @config.base_url + path
265: end
266:
267: # Builds the HTTP request body
268: #
(byebug) path
"/%2Fpulp%2Fapi%2Fv3%2Frepositories%2F9be3daf5-0831-4b84-ab54-9b1b5ceffe16%2F"
- Status changed from NEW to MODIFIED
- Sprint/Milestone set to 3.0.0
- Status changed from MODIFIED to CLOSED - CURRENTRELEASE
We are removing the 'API' category per open floor discussion June 16, 2020.
Also available in: Atom
PDF
Problem: ruby client is generated with encoded URL
Solution: ping version of openapi-generator-cli to v4.0.0
This version of openapi-generator does not have the patch that causes the encoding of the URL.
fixes: #4904 https://pulp.plan.io/issues/4904