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 1122257 - Receive HTTP 500 after issuing HTTP POST with non-JSON request body
Summary: Receive HTTP 500 after issuing HTTP POST with non-JSON request body
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: API
Version: Unspecified
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: Unspecified
Assignee: Ohad Levy
QA Contact: jcallaha
URL: http://projects.theforeman.org/issues...
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-07-22 19:27 UTC by jaudet
Modified: 2021-07-21 15:29 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-07-27 08:43:08 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 6774 0 None None None 2016-04-22 15:58:05 UTC
Red Hat Product Errata RHBA-2016:1500 0 normal SHIPPED_LIVE Red Hat Satellite 6.2 Base Libraries 2016-07-27 12:24:38 UTC

Description jaudet 2014-07-22 19:27:32 UTC
Description of problem:
Issuing an HTTP POST request to (thus far) absolutely any URL results in an HTTP 500 error. This occurs when credentials are not supplied with the request.

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 POST request to any URL, and do not provide credentials.
2. Examine the status code of the response.
3. See an HTTP 500. :(

Actual results:
HTTP 500

Expected results:
HTTP 401

Additional info:
Relevant test code can be seen here: https://github.com/omaciel/robottelo/blob/master/tests/foreman/api/test_multiple_paths.py#L130-L154

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

Comment 1 RHEL Program Management 2014-07-22 19:53:56 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:52:08 UTC
Please provide foreman-debug, I cannot reproduce this.

Comment 4 jaudet 2014-07-24 15:37:59 UTC
Here's the error which appears in /var/log/foreman/production.log. I'll attach foreman-debug shortly.


NoMethodError (undefined method `each' for nil:NilClass):
  lib/middleware/catch_json_parse_errors.rb:9:in `call'



NoMethodError (undefined method `each' for nil:NilClass):
  lib/middleware/catch_json_parse_errors.rb:9:in `call'



NoMethodError (undefined method `each' for nil:NilClass):
  lib/middleware/catch_json_parse_errors.rb:9:in `call'



NoMethodError (undefined method `each' for nil:NilClass):
  lib/middleware/catch_json_parse_errors.rb:9:in `call'



(over and over and over again)

Comment 5 jaudet 2014-07-24 15:43:34 UTC
I've uploaded a file named "foreman-debug-308di.tar.xz" using foreman-debug.

Comment 6 Dominic Cleal 2014-07-24 16:17:12 UTC
Thanks, I managed to reproduce it with robotello against EL6.  Here's a simplified reproducer:

curl -d "null" -H "Content-type: application/json" http://foreman.example.com/api/v2/hosts

Comment 7 Dominic Cleal 2014-07-24 16:17:47 UTC
Created redmine issue http://projects.theforeman.org/issues/6774 from this bug

Comment 8 jaudet 2014-07-24 16:43:22 UTC
Nice job filing the redmine issue. I didn't know about the malformed JSON bug.

Comment 9 jaudet 2014-08-07 20:49:02 UTC
I don't believe that the title of this bug accurately reflects what's going on. How about "Receive HTTP 500 after issuing unauthorized POST request"?

Comment 10 Dominic Cleal 2014-08-08 08:09:24 UTC
Whether the request is authorised or not seems to make no difference.  The issue was in the parsing of the request body, which in the test case was the string "null" (not valid JSON).

Comment 11 jaudet 2014-08-08 14:29:20 UTC
Ahaa. I've just double-checked my test code, and what you've said makes sense. I'll change back the bug title.

Comment 12 Bryan Kearney 2015-02-08 21:03:04 UTC
Moving to POST since upstream bug http://projects.theforeman.org/issues/6774 has been closed
-------------
Tom Caspy
Applied in changeset commit:44dbdbc3b5d9bba1a3e81825abc4430a7f99d753.

Comment 13 Bryan Kearney 2015-02-18 22:22:08 UTC
Upstream bug assigned to tcaspy

Comment 14 jcallaha 2015-11-10 21:47:51 UTC
Verified in upstream. Submitted a POST to api/v2/locations/ with an improperly formatted body. Received:

{
  "error": {
    "message": "Unable to authenticate user "
  }
}

Comment 15 jcallaha 2015-11-10 21:48:58 UTC
Version information:

  RELEASE: Red Hat Enterprise Linux Server release 7.1 (Maipo)
  FOREMAN: 1.11.0-develop
     RUBY: ruby 2.0.0p598 (2014-11-13) [x86_64-linux]
   PUPPET: 3.8.4

Comment 19 errata-xmlrpc 2016-07-27 08:43:08 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


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