Hide Forgot
Description of problem: If a product is created in candlepin with an id that contains a space (e.g. "c1 p2"), the href stored for the product is not url encoded (or cannot be retrieved using an encoded url). Version-Release number of selected component (if applicable): using packages: candlepin-0.3.5-1.fc14.noarch candlepin-tomcat6-0.3.5-1.fc14.noarch How reproducible: always Steps to Reproduce: 1. create a product via the API where the ID contains a space. E.g. POST /candlepin/product {"name":"c1 p2","multiplier":1,"attributes":[],"id":"c1 p2"} 2. attempt to retrieve the product using the api. E.g. GET /candlepin/products/c1+p2 3. returns an error similar to: {"displayMessage":"Product with UUID {0} could not be found"} Actual results: Expected results: Additional info:
Better example of the problem can be found in this example: { "name": "c1 p2", "id": "c1 p2", "attributes": [ ], "multiplier": 1, "productContent": [ ], "dependentProductIds": [ ], "href": "/products/c1 p2", "updated": "2011-04-27T15:39:46.377+0000", "created": "2011-04-27T15:39:46.377+0000" } Noticed the space in the href.
This led to a change in the way id's are handled. When a product is sent from Katello to Candlepin, an attribute of 'custom: true' is sent in the JSON. An id will be generated in Candlepin and included in the return JSON. This id will be numeric. Katello will incorporate the new id into the product and it will be used going forward. This id will be URL friendly and can be used without encoding.
Verifying Version... [root@jsefler-f14-5beakerpin candlepin]# git show-ref | egrep 0.3$ 49d64245b40792bcda897c732d608a1fbcd4b89b refs/heads/0.3 49d64245b40792bcda897c732d608a1fbcd4b89b refs/remotes/origin/0.3 [jsefler@jsefler ~]$ curl -k -u anybody:password --request GET https://jsefler-f14-5beakerpin.usersys.redhat.com:8443/candlepin/status { "version" : "0.3.13", "result" : true, "release" : "1%{?dist}" } [jsefler@jsefler ~]$curl -k -u admin:admin --request POST --data '{"custom":true,"name":"c1 p2","multiplier":1,"attributes":[],"id":"c1 p2"}' --header 'accept: application/json' --header 'content-type: application/json' https://jsefler-f14-5beakerpin.usersys.redhat.com:8443/candlepin/products { "name" : "c1 p2", "id" : "1306868982623", "attributes" : [ ], "multiplier" : 1, "productContent" : [ ], "custom" : true, "dependentProductIds" : [ ], "href" : "/products/1306868982623", "updated" : "2011-05-31T19:09:42.623+0000", "created" : "2011-05-31T19:09:42.623+0000" } ^^^ Notice that when I included the "custom":true in the JSON as indicated in the comment 2 design, the "id":"c1 p2" that I specified was clobbered and replaced by a candlepin generated unique "id":"1306868982623". Now I can request GET with a valid href (which is absent of spaces) and the expected product will be returned... [jsefler@jsefler ~]$ curl -k -u admin:admin --request GET https://jsefler-f14-5beakerpin.usersys.redhat.com:8443/candlepin/products/1306868982623 { "name" : "c1 p2", "id" : "1306868982623", "attributes" : [ ], "multiplier" : 1, "productContent" : [ ], "custom" : true, "dependentProductIds" : [ ], "href" : "/products/1306868982623", "updated" : "2011-05-31T19:09:42.623+0000", "created" : "2011-05-31T19:09:42.623+0000" } ^^^ VERIFIED Note: The product creation is backward compatible defaulting to a custom=false product, and the product id/href is still generated from the id explicitly supplied.... [jsefler@jsefler ~]$ curl -k -u admin:admin --request POST --data '{"name":"c1 p2 3","multiplier":1,"attributes":[],"id":"explicitly supplied id"}' --header 'accept: application/json' --header 'content-type: application/json' https://jsefler-f14-5beakerpin.usersys.redhat.com:8443/candlepin/products { "name" : "c1 p2 3", "id" : "explicitly supplied id", "attributes" : [ ], "multiplier" : 1, "productContent" : [ ], "custom" : false, "dependentProductIds" : [ ], "href" : "/products/explicitly supplied id", "updated" : "2011-05-31T19:33:21.494+0000", "created" : "2011-05-31T19:33:21.494+0000" } ^^^ Also Note as indicated in the comment 0 that this href will fail due to the spaces... [jsefler@jsefler ~]$ curl -k -u admin:admin --request GET https://jsefler-f14-5beakerpin.usersys.redhat.com:8443/candlepin/products/explicitly supplied id { "displayMessage" : "Product with UUID {0} could not be found" curl: (6) Couldn't resolve host 'supplied' curl: (6) Couldn't resolve host 'id' moving to VERIFIED