Red Hat Satellite engineering is moving the tracking of its product development work on Satellite to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1480508 - [Satellite 6.2.10] API call of GET /katello/api/host_collections results in {"displayMessage":"undefined method `id' for nil:NilClass","errors":["undefined method `id' for nil:NilClass"]}
Summary: [Satellite 6.2.10] API call of GET /katello/api/host_collections results in ...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Host Collections
Version: 6.2.10
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: Unspecified
Assignee: Anand Agrawal
QA Contact: Nikhil Kathole
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-08-11 09:41 UTC by Tapomoy Bhowmik
Modified: 2021-06-10 12:47 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-02-21 16:54:17 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 20574 0 Normal Closed API call of GET /katello/api/host_collections says organization_id optional, but doesn't accept without organization id 2021-02-10 20:25:22 UTC

Description Tapomoy Bhowmik 2017-08-11 09:41:36 UTC
Description of problem: `organization_id` parameter is mentioned as optional for `host_collections` API. Without the `organization_id` parameter, API is unable to list all the host collections rather throws below error.

====================
[root@satellite ~]# curl -s -X GET -k -u admin:<password>  'https://<satellite.example.com>/katello/api/v2/host_collections'
{"displayMessage":"undefined method `id' for nil:NilClass","errors":["undefined method `id' for nil:NilClass"]}
[root@satellite ~]# 
====================

The desired output is obtained when the below command is used with `organization_id` parameter.

====================
# curl -s -X GET -k -u admin:<password> 'https://<satellite.example.com>/api/v2/hosts?organization_id=<organization_id>&page=1&paged=true&search=host_collection_id%3D1&sort_by=name&sort_order=ASC'  | json_reformat
====================


Version-Release number of selected component (if applicable): Satellite 6.2.10


How reproducible: Always


Steps to Reproduce:
1. # curl -s -X GET -k -u admin:<password>  'https://<satellite.example.com>/katello/api/v2/host_collections'
2.
3.

Actual results:

====================
[root@satellite ~]# curl -s -X GET -k -u admin:<password>  'https://<satellite.example.com>/katello/api/v2/host_collections'
{"displayMessage":"undefined method `id' for nil:NilClass","errors":["undefined method `id' for nil:NilClass"]}
[root@satellite ~]# 
====================


Expected results: Should list all the host collections.


Additional info:

Comment 2 Satellite Program 2017-08-29 02:16:02 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue http://projects.theforeman.org/issues/20574 has been resolved.

Comment 3 Nikhil Kathole 2017-10-09 11:15:58 UTC
VERIFIED

Version Tested:
Satellite-6.3 Snap 19

steps:

1. curl -s -X GET -k -u admin:<password> 'https://<satellite>/katello/api/v2/host_collection
s'| json_reformat
{
    "total": 3,
    "subtotal": 3,
    "page": 1,
    "per_page": 20,
    "error": null,
    "search": null,
    "sort": {
        "by": "name",
        "order": "asc"
    },
    "results": [
        {
            "name": "host-collection2",
            "organization_id": 1,
            "max_hosts": null,
            "description": null,
            "total_hosts": 0,
            "unlimited_hosts": true,
            "created_at": "2017-10-09 10:58:02 UTC",
            "updated_at": "2017-10-09 10:58:02 UTC",
            "id": 2,
            "permissions": {
                "deletable": true,
                "editable": true
            }
        },
        {
            "name": "host_collection_testing",
            "organization_id": 3,
            "max_hosts": null,
            "description": null,
            "total_hosts": 0,
            "unlimited_hosts": true,
            "created_at": "2017-10-09 11:00:14 UTC",
            "updated_at": "2017-10-09 11:00:14 UTC",
            "id": 3,
            "permissions": {
                "deletable": true,
                "editable": true
            }
        },
        {
            "name": "test_hostcollection",
            "organization_id": 1,
            "max_hosts": null,
            "description": null,
            "total_hosts": 0,
            "unlimited_hosts": true,
            "created_at": "2017-10-09 09:42:16 UTC",
            "updated_at": "2017-10-09 09:42:16 UTC",
            "id": 1,
            "permissions": {
                "deletable": true,
                "editable": true
            }
        }
    ]
}


2. curl -s -X GET -k -u admin:<password> 'https://<satellite>/katello/api/v2/host_collections?organization_id=3'| json_reformat
{
    "total": 1,
    "subtotal": 1,
    "page": 1,
    "per_page": 20,
    "error": null,
    "search": null,
    "sort": {
        "by": "name",
        "order": "asc"
    },
    "results": [
        {
            "name": "host_collection_testing",
            "organization_id": 3,
            "max_hosts": null,
            "description": null,
            "total_hosts": 0,
            "unlimited_hosts": true,
            "created_at": "2017-10-09 11:00:14 UTC",
            "updated_at": "2017-10-09 11:00:14 UTC",
            "id": 3,
            "permissions": {
                "deletable": true,
                "editable": true
            }
        }
    ]

Successfully list all the host collections.

Comment 4 Satellite Program 2018-02-21 16:54:17 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/RHSA-2018:0336


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