Bug 1133071

Summary: Fetching a non-existent system returns HTTP 400 (bad request), not 404 (not found)
Product: Red Hat Satellite Reporter: jaudet
Component: APIAssignee: Bryan Kearney <bkearney>
Status: CLOSED ERRATA QA Contact: Katello QA List <katello-qa-list>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.0.6CC: chrobert, jaudet, jsherril, omaciel
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-07-27 08:44:14 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 Flags
A traceback from /var/log/foreman/production.log. none

Description jaudet 2014-08-22 15:33:46 UTC
Created attachment 929687 [details]
A traceback from /var/log/foreman/production.log.

Description of problem:
Issuing an HTTP GET request to /katello/api/v2/systems/:uuid returns an HTTP 400 response if the requested system does not exist. This is improper: an HTTP 400 response indicates that the request uses bad syntax. Fetching a non-existent system should return an HTTP 404 error, indicating that a non-existent resource was requested.

Version-Release number of selected component (if applicable):
This behaviour has been tested against qetello02.usersys.redhat.com, which is running Satellite 6.0.4. The following software is installed:

* apr-util-ldap-1.3.9-3.el6_0.1.x86_64
* candlepin-0.9.23-1.el6_5.noarch
* candlepin-common-1.0.1-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.23-1.el6_5.noarch
* candlepin-tomcat6-0.9.23-1.el6_5.noarch
* elasticsearch-0.90.10-6.el6sat.noarch
* foreman-1.6.0.40-1.el6sat.noarch
* foreman-compute-1.6.0.40-1.el6sat.noarch
* foreman-gce-1.6.0.40-1.el6sat.noarch
* foreman-libvirt-1.6.0.40-1.el6sat.noarch
* foreman-ovirt-1.6.0.40-1.el6sat.noarch
* foreman-postgresql-1.6.0.40-1.el6sat.noarch
* foreman-proxy-1.6.0.28-1.el6sat.noarch
* foreman-selinux-1.6.0.9-1.el6sat.noarch
* foreman-vmware-1.6.0.40-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.59-1.el6sat.noarch
* openldap-2.4.23-32.el6_4.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

How reproducible:
100%

Steps to Reproduce:
1. Issue an HTTP GET to /katello/api/v2/systems/:uuid, where the requested system does not exist.

Actual results:
An HTTP 400 response.

Expected results:
An HTTP 404 response.

Additional info:
This is an example of the message attached to one of the HTTP 400 error messages received:

    {
        u'displayMessage':
            u'Katello::Resources::Candlepin::Consumer: 404 Resource Not Found
            {"displayMessage":"Consumer with id abc123 could not be
            found.","requestUuid":"5d0f64df-e373-4273-b00e-6f1977bc3865"} (GET
            /candlepin/consumers/abc123)',
        u'errors': [
            u'Katello::Resources::Candlepin::Consumer: 404 Resource Not Found
            {"displayMessage":"Consumer with id abc123 could not be
            found.","requestUuid":"5d0f64df-e373-4273-b00e-6f1977bc3865"} (GET
            /candlepin/consumers/abc123)'
        ]
    }

Comment 2 jaudet 2014-08-22 15:48:19 UTC
A test has been created which targets this bug. See here: https://github.com/omaciel/robottelo/blob/master/tests/foreman/api/test_system_v2.py#L71-L101

Comment 3 Justin Sherrill 2016-02-25 18:03:14 UTC
The /systems api is deprecated in favor of the /hosts api.  Satellite 6.2 embraces this in a big way by adding content and subscription attributes to the /hosts api and I have confirmed that this returns a 404 properly.

Moving this to POST to be tested against the /hsots api

Comment 7 errata-xmlrpc 2016-07-27 08:44:14 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2016:1500