Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
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 1139576

Summary: creating/updating activation-key with long integer value under content-host limit raises PGError: integer out of range
Product: Red Hat Satellite Reporter: Sachin Ghai <sghai>
Component: WebUIAssignee: Christine Fouant <cfouant>
WebUI sub component: Katello QA Contact: Sachin Ghai <sghai>
Status: CLOSED ERRATA Docs Contact:
Severity: low    
Priority: unspecified CC: bbuckingham, bkearney, jcallaha, jmontleo
Version: 6.0.4Keywords: Triaged
Target Milestone: Unspecified   
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
URL: http://projects.theforeman.org/issues/8220
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-08-12 05:16:10 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
complete logs from production.log
none
PGError: ERROR: integer out of range : On updating content-host limit to long integer value
none
error thrown twice and with unknown range, is is expected range ? none

Description Sachin Ghai 2014-09-09 08:52:02 UTC
Created attachment 935588 [details]
complete logs from production.log

Description of problem:
I defined a long integer value under content-host limit field, while creating activation-key and nothing happens on save. The form neither submitted nor UI raised any error. But production.log filled with a long traceback.
Similar issue on update, but on update, UI raises error.

production.log on create:

---
Processing by Katello::Api::V2::ActivationKeysController#create as JSON
  Parameters: {"unlimited_content_hosts"=>false, "name"=>"test_key", "max_content_hosts"=>1.1111111111111111e+42, "environment"=>{"id"=>244, "name"=>"Library", "selected"=>true}, "content_view_id"=>255, "organization_id"=>"209", "api_version"=>"v2", "activation_key"=>{"name"=>"test_key", "organization_id"=>"209", "max_content_hosts"=>1.1111111111111111e+42, "content_view_id"=>255, "unlimited_content_hosts"=>false}}
PGError: ERROR:  value "1111111111111111126596901884379344347856896" is out of range for type integer
: INSERT INTO "katello_activation_keys" ("content_view_id", "cp_id", "created_at", "description", "environment_id", "max_content_hosts", "name", "organization_id", "release_version", "unlimited_content_hosts", "updated_at", "user_id") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12) RETURNING "id" (ActiveRecord::StatementInvalid)
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:1171:in `get_last_result'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:1171:in `exec_cache'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:665:in `block in exec_query'
---

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

How reproducible:
always

Steps to Reproduce:
1. define long integer value (11111111111111) under content-host limit field while creating/updating a activation-key
2.
3.

Actual results:
PGError: ERROR:  value "1111111111111111126596901884379344347856896" is out of range for type integer

Expected results:
UI should throw proper validation error or Content-Host limit field should be highlighted with red border.

Additional info:

Comment 2 Sachin Ghai 2014-09-09 08:55:39 UTC
Created attachment 935589 [details]
PGError: ERROR: integer out of range : On updating content-host limit to long integer value

Comment 3 Christine Fouant 2014-10-30 15:36:27 UTC
Created redmine issue http://projects.theforeman.org/issues/8220 from this bug

Comment 4 Bryan Kearney 2014-11-06 17:04:09 UTC
Moving to POST since upstream bug http://projects.theforeman.org/issues/8220 has been closed
-------------
Christine Fouant
Applied in changeset commit:katello|d2bcce043c3057700d92e1f0e2b0389f4fb8539c.

Comment 7 Sachin Ghai 2015-02-13 08:37:22 UTC
Verified with:
Satellite-6.1.0-RHEL-6-20150210.0
Sat6.1.0 beta snap2


On creating actvation-key with below content-host limit:
"1111111111111111126596901884379344347856896", error thrown on UI:

must be less than 2147483648

This error appears twice. Also with long traceback in production.log. Is this message expected ?

Processing by Katello::Api::V2::ActivationKeysController#create as JSON
  Parameters: {"unlimited_content_hosts"=>false, "max_content_hosts"=>1.1111111111111111e+42, "name"=>"ak1", "environment"=>{"id"=>5, "name"=>"Library", "label"=>"Library", "description"=>nil, "organization"=>{"name"=>"testorg", "label"=>"testorg", "id"=>3}, "created_at"=>"2015-02-13T01:13:49Z", "updated_at"=>"2015-02-13T01:13:49Z", "library"=>true, "prior"=>nil, "successor"=>nil, "counts"=>{"content_hosts"=>0, "content_views"=>0, "packages"=>0, "puppet_modules"=>0, "errata"=>{"security"=>0, "bugfix"=>0, "enhancement"=>0, "total"=>0}, "yum_repositories"=>2, "docker_repositories"=>0, "products"=>2}, "permissions"=>{"view_lifecycle_environments"=>true, "edit_lifecycle_environments"=>true, "destroy_lifecycle_environments"=>false, "promote_or_remove_content_views_to_environments"=>true}, "selected"=>true}, "content_view_id"=>3, "organization_id"=>"3", "api_version"=>"v2", "activation_key"=>{"name"=>"ak1", "organization_id"=>"3", "max_content_hosts"=>1.1111111111111111e+42, "content_view_id"=>3, "unlimited_content_hosts"=>false}}
Validation failed: Max content hosts must be less than 2147483648 (ActiveRecord::RecordInvalid)
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/validations.rb:56:in `save!'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/attribute_methods/dirty.rb:33:in `save!'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/transactions.rb:246:in `block in save!'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/transactions.rb:295:in `block in with_transaction_returning_status'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/transactions.rb:208:in `transaction'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/transactions.rb:293:in `with_transaction_returning_status'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/transactions.rb:246:in `save!'
/opt/rh/ruby193/root/usr/share/gems/gems/katello-2.2.0/app/lib/katello/lazy_accessor.rb:102:in `save!'
/opt/rh/ruby193/root/usr/share/gems/gems/katello-2.2.0/app/lib/actions/katello/activation_key/create.rb:19:in `plan'
/opt/rh/ruby193/root/usr/share/gems/gems/dynflow-0.7.3/lib/dynflow/action.rb:398:in `block (3 levels) in execute_plan'
/opt/rh/ruby193/root/usr/share/gems/gems/dynflow-0.7.3/lib/dynflow/middleware/stack.rb:26:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/dynflow-0.7.3/lib/dynflow/middleware/stack.rb:26:in `pass'
/opt/rh/ruby193/root/usr/share/gems/gems/dynflow-0.7.3/lib/dynflow/middleware.rb:16:in `pass'

Comment 8 Sachin Ghai 2015-02-13 08:39:05 UTC
Created attachment 991252 [details]
error thrown twice and with unknown range, is is expected range ?

Comment 9 Bryan Kearney 2015-02-18 23:05:11 UTC
Moving to POST since upstream bug http://projects.theforeman.org/issues/8220 has been closed
-------------
Christine Fouant
Applied in changeset commit:katello|d2bcce043c3057700d92e1f0e2b0389f4fb8539c.

Comment 11 jcallaha 2015-02-26 18:27:36 UTC
Verified in Satellite 6.1.0 snap 4 compose 2.

Version tested:
RHEL 66
RHEL 71

Comment 12 Bryan Kearney 2015-08-11 13:24:00 UTC
This bug is slated to be released with Satellite 6.1.

Comment 13 errata-xmlrpc 2015-08-12 05:16:10 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-2015:1592