Bug 1122267 - JSON data structure is inconsistent and incomplete
Summary: JSON data structure is inconsistent and incomplete
Keywords:
Status: CLOSED DUPLICATE of bug 1151240
Alias: None
Product: Red Hat Satellite 6
Classification: Red Hat
Component: API
Version: Unspecified
Hardware: Unspecified
OS: Unspecified
unspecified
medium vote
Target Milestone: Unspecified
Assignee: David Davis
QA Contact: Katello QA List
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-07-22 20:00 UTC by jaudet
Modified: 2014-10-09 21:32 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-10-09 21:32:44 UTC


Attachments (Terms of Use)
A screenshot of one of the relevant errors. (33.78 KB, image/png)
2014-07-22 20:00 UTC, jaudet
no flags Details

Description jaudet 2014-07-22 20:00:47 UTC
Created attachment 920042 [details]
A screenshot of one of the relevant errors.

Description of problem:
Issuing an HTTP GET to various URLs reveals that the structure of the JSON results is inconsistent, and the data contained within those results is incomplete. In particular, some foreign key relationships are broken. See: http://pastebin.com/QDS001Ex

Version-Release number of selected component (if applicable):
* apr-util-ldap-1.3.9-3.el6_0.1.x86_64
* candlepin-0.9.21-1.el6.noarch
* candlepin-selinux-0.9.21-1.el6.noarch
* candlepin-tomcat6-0.9.21-1.el6.noarch
* elasticsearch-0.90.10-4.el6.noarch
* foreman-1.6.0-0.develop.201407211519git93f6f75.el6.noarch
* foreman-compute-1.6.0-0.develop.201407211519git93f6f75.el6.noarch
* foreman-gce-1.6.0-0.develop.201407211519git93f6f75.el6.noarch
* foreman-libvirt-1.6.0-0.develop.201407211519git93f6f75.el6.noarch
* foreman-ovirt-1.6.0-0.develop.201407211519git93f6f75.el6.noarch
* foreman-postgresql-1.6.0-0.develop.201407211519git93f6f75.el6.noarch
* foreman-proxy-1.6.0-0.develop.201407211449git2cba606.el6.noarch
* foreman-release-1.6.0-0.develop.201407211519git93f6f75.el6.noarch
* foreman-selinux-1.6.0-0.develop.201406261522git5532684.el6.noarch
* foreman-vmware-1.6.0-0.develop.201407211519git93f6f75.el6.noarch
* katello-1.5.0-14.201407211524gitddbde13.el6.noarch
* katello-ca-1.0-1.noarch
* katello-certs-tools-1.5.2-1.git.1.edab2c4.el6.noarch
* katello-installer-0.0.19-1.201407162131gitb142720.el6.noarch
* katello-repos-1.5.1-1.git.14.0868bd1.el6.noarch
* openldap-2.4.23-31.el6.x86_64
* pulp-katello-0.3-3.el6.noarch
* pulp-nodes-common-2.4.0-0.24.beta.el6.noarch
* pulp-nodes-parent-2.4.0-0.24.beta.el6.noarch
* pulp-puppet-plugins-2.4.0-0.24.beta.el6.noarch
* pulp-puppet-tools-2.4.0-0.24.beta.el6.noarch
* pulp-rpm-plugins-2.4.0-0.24.beta.el6.noarch
* pulp-selinux-2.4.0-0.24.beta.el6.noarch
* pulp-server-2.4.0-0.24.beta.el6.noarch
* python-ldap-2.3.10-1.el6.x86_64
* ruby193-rubygem-net-ldap-0.3.1-2.el6.noarch
* ruby193-rubygem-runcible-1.1.0-1.el6.noarch

How reproducible:
100%

Steps to Reproduce:
1. Issue an HTTP GET to `katello/api/v2/content_views/:id` or `katello/api/v2/repositories/:id`.
2. Examine the JSON payload returned. In particular, look at the foreign key relationships.
3. Discover that foreign keys are named inconsistently and have an inconsistent data format.

Actual results:
Foreign keys named "<entity_name>", associated with an incomplete set of JSON data about the linked-to entity.

Expected results:
Foreign keys named "<entity_name>_id", associated with the ID of the linked-to entity.

Additional info:
A full example can be found here: http://pastebin.com/QDS001Ex

Test code which produces this outcome can be found here: https://github.com/omaciel/robottelo/blob/master/tests/foreman/api/test_multiple_paths.py#L95-L128

Pull request #1068 will cause that test code to move. If #1068 is moved, you can find the test code here instead: https://github.com/omaciel/robottelo/blob/master/tests/foreman/api/test_multiple_paths.py#L231-L310

The really relevant lines of test code are as follows: (ignore the `path` var)

> self.assertIn(key, real_attrs.keys(), path)
> self.assertEqual(value, real_attrs[key], path)

I've attached a screenshot of one of the relevant errors.

Comment 1 RHEL Product and Program Management 2014-07-22 20:24:21 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.

Comment 4 jaudet 2014-08-13 19:02:41 UTC
This issue also applies to activation keys. If one issues an HTTP GET to api/v2/activation_keys/:id, the response contains the following pieces of information:

[
    u'content_overrides',
    u'content_view',
    u'content_view_id',
    u'created_at',
    u'description',
    u'environment',
    u'environment_id',
    u'host_collections',
    u'id',
    u'max_content_hosts',
    u'name',
    u'organization',
    u'permissions',
    u'pools',
    u'products',
    u'release_version',
    u'service_level',
    u'unlimited_content_hosts',
    u'updated_at',
    u'usage_count',
    u'user_id',
]

Notice that most foreign keys add "_id" to the end of their names, such as "environment_id" and "user_id". However, there is no "organization_id" key, even though an activation key does have a foreign key relationship to an organization.

Comment 5 jaudet 2014-08-19 13:44:45 UTC
This issue is currently known to affect the following URLs:

* api/v2/activation_keys
* api/v2/content_views
* api/v2/gpg_keys
* api/v2/environments
* api/v2/repositories

Comment 6 jaudet 2014-10-09 21:32:44 UTC
Closing this bug because it is worded poorly. For a more concrete and actionable set of bug reports, see #1151220 and #1151240.

*** This bug has been marked as a duplicate of bug 1151240 ***


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