Bug 1122261 - JSON data type is wrong
Summary: JSON data type is wrong
Alias: None
Product: Red Hat Satellite 6
Classification: Red Hat
Component: API
Version: Unspecified
Hardware: Unspecified
OS: Unspecified
unspecified vote
Target Milestone: Unspecified
Assignee: Dominic Cleal
QA Contact: Jitendra Yejare
Depends On:
TreeView+ depends on / blocked
Reported: 2014-07-22 19:43 UTC by jaudet
Modified: 2019-02-25 21:56 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2014-07-24 13:58:37 UTC

Attachments (Terms of Use)
The relevant error message from the test suite. (23.15 KB, image/png)
2014-07-22 19:43 UTC, jaudet
no flags Details

Description jaudet 2014-07-22 19:43:52 UTC
Created attachment 920040 [details]
The relevant error message from the test suite.

Description of problem:
Issuing an HTTP GET request to `/api/v2/operatingsystems/:id` returns a collection of JSON-encoded data. Among this data is the ID of the operating system. This ID should be a number, but it is actually a string.

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:

Steps to Reproduce:
1. Issue HTTP GET to `api/v2/operatingsystems/:id`
2. Examine "id" field of return value
3. Discover that "id" field is a string, not a number.

Actual results:
An operating system ID, as a string.

Expected results:
An operating system ID, as a number.

Additional info:
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 line of test code is this one:

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

I've attached a screenshot of the relevant error.

Comment 1 RHEL Product and Program Management 2014-07-22 19:53:54 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 3 Dominic Cleal 2014-07-24 06:57:14 UTC
I don't follow which ID you're talking about - the screenshot shows a request to /api/v2/operatingsystems/42, which means the ID of the OS is 42.  It shows a comparison of the number "59457" though, so that can't be the OS ID?

Comment 4 jaudet 2014-07-24 13:58:37 UTC
> the screenshot shows a request to /api/v2/operatingsystems/42, which means the ID of the OS is 42.  It shows a comparison of the number "59457" though, so that can't be the OS ID?

God DAMN that is obvious and I should have noticed that earlier.

My test suite is actually compalining about the "major" attribute of the operating system returned. And upon checking the API doc... the "major" and "minor" attributes are strings.

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