Bug 700230 - Product: href is not url encoded
Summary: Product: href is not url encoded
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Candlepin
Classification: Community
Component: candlepin
Version: 0.5
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: ---
: ---
Assignee: William Poteat
QA Contact: John Sefler
URL:
Whiteboard:
Depends On:
Blocks: 675214
TreeView+ depends on / blocked
 
Reported: 2011-04-27 20:30 UTC by Brad Buckingham
Modified: 2015-05-14 15:23 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-01-04 15:30:51 UTC


Attachments (Terms of Use)

Description Brad Buckingham 2011-04-27 20:30:03 UTC
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:

Comment 1 Jesus M. Rodriguez 2011-04-28 14:54:49 UTC
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.

Comment 2 William Poteat 2011-05-11 14:30:54 UTC
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.

Comment 3 John Sefler 2011-05-31 19:39:25 UTC
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


Note You need to log in before you can comment on or make changes to this bug.