Bug 728636

Summary: duplicate activation key error is hard to decipher
Product: [Community] Candlepin Reporter: John Sefler <jsefler>
Component: candlepinAssignee: William Poteat <wpoteat>
Status: CLOSED CURRENTRELEASE QA Contact: John Sefler <jsefler>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 0.5CC: jmolet, spandey, wpoteat
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-05-30 13:13:05 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 682238    

Description John Sefler 2011-08-05 21:19:31 UTC
Description of problem:
When attempting to create an activation key using a name that has already been used, we get the following error:

Runtime Error org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError:2,598

This seems like a common enough user error to warrant an error message that is easier to understand.


Version-Release number of selected component (if applicable):
[root@jsefler-onprem-62candlepin candlepin]# git show-ref | grep master
895fdff46e33a607d63350df9bdd7bdd275b9e17 refs/heads/master
895fdff46e33a607d63350df9bdd7bdd275b9e17 refs/remotes/origin/master

How reproducible:


Steps to Reproduce:
[jsefler@jseflerT510 ~]$ curl -k --request POST --user testuser1:password --data '{"name":"DUPLICATE-KEY"}' --header 'accept: application/json' --header 'content-type: application/json'  https://jsefler-onprem-62candlepin.usersys.redhat.com:8443/candlepin/owners/admin/activation_keys | python -mjson.tool
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
108   272  100   272    0    24    586     51 --:--:-- --:--:-- --:--:--   774
{
    "created": "2011-08-05T21:13:32.095+0000", 
    "id": "8a90f8c63196bb2001319bcb38bf3a28", 
    "name": "DUPLICATE-KEY", 
    "owner": {
        "displayName": "Admin Owner", 
        "href": "/owners/admin", 
        "id": "8a90f8c63196bb20013196bb9e210006", 
        "key": "admin"
    }, 
    "pools": [], 
    "updated": "2011-08-05T21:13:32.095+0000"
}
[jsefler@jseflerT510 ~]$ curl -k --request POST --user testuser1:password --data '{"name":"DUPLICATE-KEY"}' --header 'accept: application/json' --header 'content-type: application/json'  https://jsefler-onprem-62candlepin.usersys.redhat.com:8443/candlepin/owners/admin/activation_keys | python -mjson.tool
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
111   208  100   208    0    24    462     53 --:--:-- --:--:-- --:--:--   611
{
    "displayMessage": "Runtime Error org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError:2,598"
}
[jsefler@jseflerT510 ~]$ 



  
Actual results:


Expected results:


Additional info:

Comment 1 J.C. Molet 2011-08-19 14:28:20 UTC
Looks like it works now:

[jmolet@jmolet ~]$ curl -k --request POST --user testuser1:password --data '{"name":"dupkey"}' --header 'accept: application/json' --header 'content-type: application/json' https://jsefler-onprem-62candlepin.usersys.redhat.com:8443/candlepin/owners/admin/activation_keys | python -mjson.tool
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   282  100   265  100    17    560     35 --:--:-- --:--:-- --:--:--   676
{
    "created": "2011-08-19T14:26:34.182+0000", 
    "id": "8a90f8c631c3a8100131e26faa461187", 
    "name": "dupkey", 
    "owner": {
        "displayName": "Admin Owner", 
        "href": "/owners/admin", 
        "id": "8a90f8c631c3a8100131c3a899e90006", 
        "key": "admin"
    }, 
    "pools": [], 
    "updated": "2011-08-19T14:26:34.182+0000"
}
[jmolet@jmolet ~]$ curl -k --request POST --user testuser1:password --data '{"name":"dupkey"}' --header 'accept: application/json' --header 'content-type: application/json' https://jsefler-onprem-62candlepin.usersys.redhat.com:8443/candlepin/owners/admin/activation_keys | python -mjson.tool
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   102  100    85  100    17    242     48 --:--:-- --:--:-- --:--:--   302
{
    "displayMessage": "Activation key name [dupkey] is already in use for owner [admin]"
}



[jmolet@jmolet ~]$ curl -k --request GET --user testuser1:password  https://jsefler-onprem-62candlepin.usersys.redhat.com:8443/candlepin/status | python -mjson.tool
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    48  100    48    0     0    142      0 --:--:-- --:--:-- --:--:--   187
{
    "release": "1", 
    "result": true, 
    "version": "0.4.10"
}


marking VERIFIED