Bug 1241077 - API settings unquoted integer provided gives error
Summary: API settings unquoted integer provided gives error
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Provisioning
Version: 6.1.0
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: Unspecified
Assignee: Ivan Necas
QA Contact: Tazim Kolhar
Russell Dickenson
URL: http://projects.theforeman.org/issues...
Whiteboard:
Depends On:
Blocks: 1122832 sat61-release-notes
TreeView+ depends on / blocked
 
Reported: 2015-07-08 11:53 UTC by Peter Vreman
Modified: 2019-10-10 09:55 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Issue: If you provide a numeric value to an API element which requires a numeric value, you may see the following error message. --- "Value is invalid: must be integer" --- The cause of this issue is that the value is tested with a regular expression and the numeric value fails the test. Workaround: Enclose the numeric value in quote characters (").
Clone Of:
Environment:
Last Closed: 2015-10-15 18:20:17 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2015:1911 0 normal SHIPPED_LIVE Satellite 6.1.3 bug fix update 2015-10-15 22:19:19 UTC

Description Peter Vreman 2015-07-08 11:53:50 UTC
Description of problem:

Settings unqouted Integer values are resulting in an error that an integer is required. Changing it to a quoted value does not give this error.
I would expect the otherway around that a quoted integer shall give an error instead.

This is also a regression compared to 6.0.8 that accepted the unqouted integer value.

# curl -K /opt/hoici/etc/sat6/curl-hoici.conf "-HContent-Type: application/json" "-d{\"per_page\":9999,\"setting\":{\"value\":60}}" -XPUT https://localhost/api/v2/settings/52
{
  "error": {"id":52,"errors":{"value":["is invalid: must be integer"]},"full_messages":["Value is invalid: must be integer"]}
}

# curl -K /opt/hoici/etc/sat6/curl-hoici.conf "-HContent-Type: application/json" "-d{\"per_page\":9999,\"setting\":{\"value\":\"60\"}}" -XPUT https://localhost/api/v2/settings/52
{"created_at":"2015-07-08T08:45:44Z","default":30,"description":"Puppet interval in minutes","id":52,"name":"puppet_interval","settings_type":"integer","updated_at":"2015-07-08T09:57:12Z","value":60}



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


How reproducible:


Steps to Reproduce:
1. See curl commands above
2.
3.

Actual results:
Unqouted integer value gives error

Expected results:
Unqouted integer works


Additional info:

Comment 1 RHEL Program Management 2015-07-08 12:04:48 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 Peter Vreman 2015-07-14 16:46:40 UTC
Regexes do not work with Integer, convert to String first

Patch:

--- /usr/share/foreman/app/models/setting.rb
+++ /usr/share/foreman/app/models/setting.rb
@@ -117,7 +117,7 @@
       self.value = boolean

     when "integer"
-      if val =~ /\A\d+\Z/
+      if val.to_s =~ /\A\d+\Z/
         self.value = val.to_i
       else
         invalid_value_error _("must be integer")

Comment 9 Ivan Necas 2015-09-03 08:59:03 UTC
Created redmine issue http://projects.theforeman.org/issues/11673 from this bug

Comment 10 Ivan Necas 2015-09-03 09:01:33 UTC
Fix opened against upstream https://github.com/theforeman/foreman/pull/2666

Comment 11 Bryan Kearney 2015-09-03 10:04:04 UTC
Upstream bug component is Provisioning

Comment 12 Ivan Necas 2015-09-03 10:58:03 UTC
Merged upstream

Comment 15 Tazim Kolhar 2015-10-06 10:46:16 UTC
VERIFIED:
# rpm -qa | grep foreman
ruby193-rubygem-foreman_hooks-0.3.7-2.el7sat.noarch
rubygem-hammer_cli_foreman-0.1.4.14-1.el7sat.noarch
ruby193-rubygem-foreman_bootdisk-4.0.2.13-1.el7sat.noarch
foreman-vmware-1.7.2.40-1.el7sat.noarch
rubygem-hammer_cli_foreman_bootdisk-0.1.2.7-1.el7sat.noarch
foreman-debug-1.7.2.40-1.el7sat.noarch
foreman-proxy-1.7.2.6-1.el7sat.noarch
foreman-1.7.2.40-1.el7sat.noarch
foreman-gce-1.7.2.40-1.el7sat.noarch
ruby193-rubygem-foreman-redhat_access-0.2.3-1.el7sat.noarch
rubygem-hammer_cli_foreman_discovery-0.0.1.10-1.el7sat.noarch
hp-xw6600-02.rhts.eng.bos.redhat.com-foreman-client-1.0-1.noarch
hp-xw6600-02.rhts.eng.bos.redhat.com-foreman-proxy-1.0-2.noarch
foreman-compute-1.7.2.40-1.el7sat.noarch
ruby193-rubygem-foreman_docker-1.2.0.22-1.el7sat.noarch
ruby193-rubygem-foreman-tasks-0.6.15.7-1.el7sat.noarch
rubygem-hammer_cli_foreman_tasks-0.0.3.5-1.el7sat.noarch
foreman-libvirt-1.7.2.40-1.el7sat.noarch
foreman-postgresql-1.7.2.40-1.el7sat.noarch
hp-xw6600-02.rhts.eng.bos.redhat.com-foreman-proxy-client-1.0-1.noarch
foreman-ovirt-1.7.2.40-1.el7sat.noarch
foreman-selinux-1.7.2.13-1.el7sat.noarch
ruby193-rubygem-foreman_discovery-2.0.0.19-1.el7sat.noarch
rubygem-hammer_cli_foreman_docker-0.0.3.9-1.el7sat.noarch
ruby193-rubygem-foreman_gutterball-0.0.1.9-1.el7sat.noarch


steps:

# curl -k -u admin:changeme "-HContent-Type: application/json" "-d{\"per_page\":9999,\"setting\":{\"value\":60}}" -XPUT https://hp-xw6600-02.rhts.eng.bos.redhat.com/api/v2/settings/52
{"created_at":"2015-10-05T03:00:20Z","default":null,"description":"Redirect your users to this url on logout (authorize_login_delegation should also be enabled)","id":52,"name":"login_delegation_logout_url","settings_type":null,"updated_at":"2015-10-06T10:41:22Z","value":"60"

Unqouted integer works

Comment 17 errata-xmlrpc 2015-10-15 18:20: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/RHBA-2015:1911


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