Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 1151240 - Some API URLs emit a list of IDs, and others emit a list of hashes.
Some API URLs emit a list of IDs, and others emit a list of hashes.
Status: CLOSED ERRATA
Product: Red Hat Satellite 6
Classification: Red Hat
Component: API (Show other bugs)
Nightly
Unspecified Unspecified
unspecified Severity medium (vote)
: Unspecified
: Unused
Assigned To: Partha Aji
jaudet
: Triaged
: 1122267 (view as bug list)
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2014-10-09 17:21 EDT by jaudet
Modified: 2017-02-23 15:52 EST (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2015-08-12 01:17:50 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2015:1592 normal SHIPPED_LIVE Important: Red Hat Satellite 6.1.1 on RHEL 6 2015-08-12 05:04:35 EDT

  None (edit)
Description jaudet 2014-10-09 17:21:18 EDT
Description of problem:
Some API responses contain a list of IDs, and others contain a list of hashes. 

For example, a GET request to `/gpgkeys/:id` returns data in this format:

    {u'name': u'foo', u'organization': {u'name': u'ACME', u'label': '...'}}

No organization ID is listed. This means that it is impossible to discover what organization this GPG key belongs to except by issuing a follow-up search to the `/organizations` URL (and hopefully coming up with only one result).

As a second example, a GET request to `/architectures/:id` returns data in this format:

    {
        u'name': u'i386',
        u'operatingsystems': [
            {u'id': 1, u'name': u'rhel65'},
            {u'id': 2, u'name': u'rhel7'},
        ]
    }

This is awkward. In this case, the client can compile a list of associated operating systems by iterating through the returned hashes and fetching through their IDs. It is much easier to deal with a straight list of IDs:

    {u'name': u'i386', u'operatingsystem_ids': [1, 2]}

The API should return either an ID or a list of IDs for all foreign key relationships. Client code can be simple and straightforward if a list of IDs is returned.

Version-Release number of selected component (if applicable):
This has been tested against multiple versions of Satellite. Most recently, this has been tested against a system running Satellite 6.0.4 with the following software installed:

* candlepin-0.9.23-1.el7.noarch
* candlepin-common-1.0.1-1.el7.noarch
* candlepin-guice-3.0-2_redhat_1.el7.noarch
* candlepin-scl-1-5.el7.noarch
* candlepin-scl-quartz-2.1.5-6.el7.noarch
* candlepin-scl-rhino-1.7R3-3.el7.noarch
* candlepin-scl-runtime-1-5.el7.noarch
* candlepin-selinux-0.9.23-1.el7.noarch
* candlepin-tomcat-0.9.23-1.el7.noarch
* elasticsearch-0.90.10-6.el7sat.noarch
* foreman-1.6.0.46-1.el7sat.noarch
* foreman-compute-1.6.0.46-1.el7sat.noarch
* foreman-gce-1.6.0.46-1.el7sat.noarch
* foreman-libvirt-1.6.0.46-1.el7sat.noarch
* foreman-ovirt-1.6.0.46-1.el7sat.noarch
* foreman-postgresql-1.6.0.46-1.el7sat.noarch
* foreman-proxy-1.6.0.30-1.el7sat.noarch
* foreman-selinux-1.6.0.14-1.el7sat.noarch
* foreman-vmware-1.6.0.46-1.el7sat.noarch
* katello-1.5.0-30.el7sat.noarch
* katello-certs-tools-1.5.6-1.el7sat.noarch
* katello-default-ca-1.0-1.noarch
* katello-installer-0.0.64-1.el7sat.noarch
* katello-server-ca-1.0-1.noarch
* openldap-2.4.39-3.el7.x86_64
* pulp-katello-0.3-4.el7sat.noarch
* pulp-nodes-common-2.4.1-0.7.beta.el7sat.noarch
* pulp-nodes-parent-2.4.1-0.7.beta.el7sat.noarch
* pulp-puppet-plugins-2.4.1-0.7.beta.el7sat.noarch
* pulp-puppet-tools-2.4.1-0.7.beta.el7sat.noarch
* pulp-rpm-plugins-2.4.1-0.7.beta.el7sat.noarch
* pulp-selinux-2.4.1-0.7.beta.el7sat.noarch
* pulp-server-2.4.1-0.7.beta.el7sat.noarch
* python-ldap-2.4.6-6.el7.x86_64
* ruby193-rubygem-net-ldap-0.3.1-3.el7sat.noarch
* ruby193-rubygem-runcible-1.1.0-2.el7sat.noarch

How reproducible:
100%, but the exact response of each API URL varies.

Steps to Reproduce:
See the "Description of problem" section of this bug report.

Actual results:
A hash or list of hashes that may or may not contain IDs.

Expected results:
An ID or list of IDs.

Additional info:
n/a
Comment 1 jaudet 2014-10-09 17:29:02 EDT
A test which targets this bug for one of the API URLs has been submitted. See: https://github.com/SatelliteQE/robottelo/pull/1545
Comment 2 jaudet 2014-10-09 17:31:19 EDT
This bug report claims that "Client code can be simple and straightforward if a list of IDs is returned." For an example of the workarounds that are required when hashes are returned, search for the phrase "1151240" in this file: https://github.com/SatelliteQE/robottelo/blob/master/robottelo/entities.py

Searching for that phrase may not work until pull request #1545 is merged.
Comment 3 jaudet 2014-10-09 17:32:44 EDT
*** Bug 1122267 has been marked as a duplicate of this bug. ***
Comment 4 RHEL Product and Program Management 2014-10-09 17:33:05 EDT
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.
Comment 6 Dominic Cleal 2014-10-21 11:55:07 EDT
The first example of gpgkeys is the problem here, it should include the ID in the output for an individual organisation.

The latter format may be standardised in APIv3 in the future.
Comment 7 jaudet 2014-10-23 14:29:40 EDT
I'm happy to hear that this may be included in APIv3.
Comment 11 jaudet 2015-03-04 11:20:47 EST
Tested against Satellite-6.1.0-RHEL-6-20150303.0 and Satellite-6.1.0-RHEL-7-20150303.0.
Comment 12 Bryan Kearney 2015-08-11 09:20:44 EDT
This bug is slated to be released with Satellite 6.1.
Comment 13 errata-xmlrpc 2015-08-12 01:17:50 EDT
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/RHSA-2015:1592

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