Bug #8220
closedcreating/updating activation-key with long integer value under content-host limit raises PGError: integer out of range
Description
Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=1139576
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: