Bug 1116043
Summary: | Cannot create an organization. | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Product: | Red Hat Satellite | Reporter: | jaudet | ||||||||||
Component: | API | Assignee: | David Davis <daviddavis> | ||||||||||
Status: | CLOSED CURRENTRELEASE | QA Contact: | sthirugn <sthirugn> | ||||||||||
Severity: | medium | Docs Contact: | |||||||||||
Priority: | unspecified | ||||||||||||
Version: | Nightly | CC: | bbuckingham, cwelton, daviddavis, ehelms, jaudet, jmontleo, omaciel, sthirugn | ||||||||||
Target Milestone: | Unspecified | Keywords: | Triaged | ||||||||||
Target Release: | Unused | ||||||||||||
Hardware: | Unspecified | ||||||||||||
OS: | Unspecified | ||||||||||||
URL: | http://projects.theforeman.org/issues/6786 | ||||||||||||
Whiteboard: | |||||||||||||
Fixed In Version: | Doc Type: | Bug Fix | |||||||||||
Doc Text: | Story Points: | --- | |||||||||||
Clone Of: | Environment: | ||||||||||||
Last Closed: | 2014-09-11 12:20:16 UTC | Type: | Bug | ||||||||||
Regression: | --- | Mount Type: | --- | ||||||||||
Documentation: | --- | CRM: | |||||||||||
Verified Versions: | Category: | --- | |||||||||||
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||||||||
Cloudforms Team: | --- | Target Upstream Version: | |||||||||||
Embargoed: | |||||||||||||
Attachments: |
|
Description
jaudet
2014-07-03 14:37:46 UTC
Since this issue was entered in Red Hat Bugzilla, the release flag has been set to ? to ensure that it is properly evaluated for this release. If possible, can you attach the server log for the scenario? (e.g. /var/log/foreman/production.log). Created attachment 916857 [details]
Log output when creating an org.
Log output when creating an org and specifying a name of "foo".
Created attachment 916858 [details]
Lot output when creating an org.
In this case, am creating an org and specifying a name, description and label.
Created attachment 916860 [details]
Log output when creating an org.
In this case, am creating an org and only specifying a name for that org. The name is a randomly-generated UTF-8 string.
I've attached three server logs. 1. In the first log, only a name is provided for the organization. 2. In the second log, a name, label and description is provided. 3. In the third log, I let the factory generate random UTF-8 values for the organization name. In all three cases, I simply copied output from `tail -f /var/log/foreman/production.log`. This bug appears to occur only when the request header "content-type" is set to "application/json". Ugh. The above should say 'not set to "application/json"'. Test code has been written to explicitly target this bug. See here: https://github.com/omaciel/robottelo/blob/master/tests/foreman/api/test_organization_v2.py Currently there is a workaround that involves using nested params: Instead of { "name" : "my org" } use { "organization": { "name" : "my org"}} To clarify: this bug only occurs when the request header "content-type" is not set to "application/json". In other words: * If the content-type is set to application/json, you can create an organization. * If the content-type is set to text/plain, you cannot create an organization. jaudet, does robletto test both content-types? Bryan, Robottelo currently focuses on the application/json content-type. There are very few tests that have a content-type of text/plain. If robottelo was fleshed out with a greater set of tests that used the text/plain content-type, there would be a *lot* more bugs landing in the dev team's queue. There's already a Foreman issue open about this (http://projects.theforeman.org/issues/6446). Basically we need to either (1) support non-JSON requests or (2) show a user friendly error. I'm happy to tackle the open foreman issue but I'm not sure which solution Foreman wants to implement. I'll send a message to the foreman-dev list and then try to fix it if there's a consensus. Actually, I can fix the nil error in this bug but then you're just going to get a 400 error saying that name can't be blank. Created redmine issue http://projects.theforeman.org/issues/6786 from this bug Bryan, do you mind if I steal this from you? Moving to POST since upstream bug http://projects.theforeman.org/issues/6786 has been closed ------------- David Davis I opened a PR to prevent the nil error from being raised. This might suffice as a solution for this bug: https://github.com/theforeman/foreman/pull/1619 Waiting to here on people's opinions on foreman-dev. ------------- David Davis Applied in changeset commit:f5317a04def5c415632190c9c49d95d60f3d83af. GitHub pull request #1143 updates the test suite to reflect the changes that have been made. See: https://github.com/omaciel/robottelo/pull/1143 Tested three scenarios here: 1. Content-Type: application/json - Success! PASS curl -X POST -H "Accept:application/json" -H "Content-Type: application/json" -u admin:changeme --insecure -d '{"name":"testorgapi"}' https://host/katello/api/v2/organizations Success! 2. Content-Type: application/xml - Failed # curl -X POST -H "Accept:application/xml" -H "Content-Type: application/xml" -u admin:changeme --insecure -d '<name>testorgapi</name>' https://host/katello/api/v2/organizations { "error": {"id":null,"errors":{"name":["can't be blank","can't be blank","cannot be blank"],"title":["can't be blank"],"label":["can't be blank","can't be blank","can't be blank"]},"full_messages":["Name can't be blank","Name can't be blank","Name cannot be blank","Title can't be blank","Label can't be blank","Label can't be blank","Label can't be blank"]} 3. Content-Type: text/plain - Failed #curl -X POST -H "Accept:application/xml" -H "Content-Type: text/plain" -u admin:changeme --insecure -d 'name=testorgapi' https://host/katello/api/v2/organizations { "error": {"id":null,"errors":{"name":["can't be blank","can't be blank","cannot be blank"],"title":["can't be blank"],"label":["can't be blank","can't be blank","can't be blank"]},"full_messages":["Name can't be blank","Name can't be blank","Name cannot be blank","Title can't be blank","Label can't be blank","Label can't be blank","Label can't be blank"]} Verified as per my Comment 24 above. Created a new issue for unsupported media types issue - https://bugzilla.redhat.com/show_bug.cgi?id=1129769 Version Tested: GA Snap 4 - Satellite-6.0.4-RHEL-6-20140806.0 * apr-util-ldap-1.3.9-3.el6_0.1.x86_64 * candlepin-0.9.19-1.el6_5.noarch * candlepin-scl-1-5.el6_4.noarch * candlepin-scl-quartz-2.1.5-5.el6_4.noarch * candlepin-scl-rhino-1.7R3-1.el6_4.noarch * candlepin-scl-runtime-1-5.el6_4.noarch * candlepin-selinux-0.9.19-1.el6_5.noarch * candlepin-tomcat6-0.9.19-1.el6_5.noarch * elasticsearch-0.90.10-4.el6sat.noarch * foreman-1.6.0.38-1.el6sat.noarch * foreman-compute-1.6.0.38-1.el6sat.noarch * foreman-gce-1.6.0.38-1.el6sat.noarch * foreman-libvirt-1.6.0.38-1.el6sat.noarch * foreman-ovirt-1.6.0.38-1.el6sat.noarch * foreman-postgresql-1.6.0.38-1.el6sat.noarch * foreman-proxy-1.6.0.23-1.el6sat.noarch * foreman-selinux-1.6.0.4-1.el6sat.noarch * foreman-vmware-1.6.0.38-1.el6sat.noarch * katello-1.5.0-28.el6sat.noarch * katello-ca-1.0-1.noarch * katello-certs-tools-1.5.6-1.el6sat.noarch * katello-installer-0.0.57-1.el6sat.noarch * openldap-2.4.23-34.el6_5.1.x86_64 * pulp-katello-0.3-3.el6sat.noarch * pulp-nodes-common-2.4.0-0.30.beta.el6sat.noarch * pulp-nodes-parent-2.4.0-0.30.beta.el6sat.noarch * pulp-puppet-plugins-2.4.0-0.30.beta.el6sat.noarch * pulp-puppet-tools-2.4.0-0.30.beta.el6sat.noarch * pulp-rpm-plugins-2.4.0-0.30.beta.el6sat.noarch * pulp-selinux-2.4.0-0.30.beta.el6sat.noarch * pulp-server-2.4.0-0.30.beta.el6sat.noarch * python-ldap-2.3.10-1.el6.x86_64 * ruby193-rubygem-net-ldap-0.3.1-3.el6sat.noarch * ruby193-rubygem-runcible-1.1.0-2.el6sat.noarch * sssd-ldap-1.11.5.1-3.el6.x86_64 This was delivered with Satellite 6.0 which was released on 10 September 2014. |