Project

General

Profile

Bug #7038

PGError when hostgroup name exceeds 245 characters

Added by Dominic Cleal almost 5 years ago. Updated 11 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Database
Target version:
Difficulty:
Triaged:
Bugzilla link:
Team Backlog:
Fixed in Releases:
Found in Releases:

Description

Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=1129202
Description of problem:
I was trying to validate the hostgroup form and found that if we enter more than 245 chars in 'Name' field of hostgroup, It raises PGError:

--
Processing by HostgroupsController#update as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"8YKMIr6xgzHyJpwH0LC3VbHzoQSwOk+VOG2XoH0FhiE=", "hostgroup"=>{"name"=>"SSTQOPqJiwFllLmBmDRZoWsarPNwQhcEypKFfTozMHnmPtTqkgebNCMSMxBdywiWmEbraUdMnjnSIvdKFeioxAgvPTutMitBTTRExegkJRTzxlAHDIasfjwEAabNhzvevKiTDbYXbaqVFArexnApWfavHFpPSoDothzHwKVZOYrqGtSicQxHHrBoLcuNwrANGduNLMCurtGjlrkweKZNVqDaxmOPfvHBQjwapFpfbhLxGPksMwxGn1", "environment_id"=>"", "content_source_id"=>"", "puppet_ca_proxy_id"=>"", "puppet_proxy_id"=>"", "domain_id"=>"", "realm_id"=>"", "architecture_id"=>"", "root_pass"=>"[FILTERED]", "location_ids"=>[""], "organization_ids"=>[""]}, "kt_environment_id"=>"", "kt_activation_keys"=>"", "commit"=>"Submit", "id"=>"16-sstqopqjiwflllmbmdrzowsarpnwqhceypkfftozmhnmpttqkgebncmsmxbdywiwmebraudmnjnsivdkfeioxagvptutmitbttrexegkjrtzxlahdiasfjweaabnhzvevkitdbyxbaqvfarexnapwfavhfppsodothzhwkvzoyrqgtsicqxhhrbolcunwrangdunlmcurtgjlrkwekznvqdaxmopfvhbqjwapfpfbhlxgpksmwxgn"}
Operation FAILED: PGError: ERROR: value too long for type character varying(255)
: UPDATE "lookup_values" SET "match" = 'hostgroup=SSTQOPqJiwFllLmBmDRZoWsarPNwQhcEypKFfTozMHnmPtTqkgebNCMSMxBdywiWmEbraUdMnjnSIvdKFeioxAgvPTutMitBTTRExegkJRTzxlAHDIasfjwEAabNhzvevKiTDbYXbaqVFArexnApWfavHFpPSoDothzHwKVZOYrqGtSicQxHHrBoLcuNwrANGduNLMCurtGjlrkweKZNVqDaxmOPfvHBQjwapFpfbhLxGPksMwxGn1' WHERE "lookup_values"."match" = 'hostgroup=SSTQOPqJiwFllLmBmDRZoWsarPNwQhcEypKFfTozMHnmPtTqkgebNCMSMxBdywiWmEbraUdMnjnSIvdKFeioxAgvPTutMitBTTRExegkJRTzxlAHDIasfjwEAabNhzvevKiTDbYXbaqVFArexnApWfavHFpPSoDothzHwKVZOYrqGtSicQxHHrBoLcuNwrANGduNLMCurtGjlrkweKZNVqDaxmOPfvHBQjwapFpfbhLxGPksMwxGn'
Rendered common/500.html.erb within layouts/application (5.7ms)
Rendered layouts/base.html.erb (1.4ms)
Completed 500 Internal Server Error in 67ms (Views: 9.7ms | ActiveRecord: 8.1ms)
---

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

How reproducible:
always

Steps to Reproduce:
1. create hostgroup with more than 245 char in name
2.
3.

Actual results:
Operation FAILED: PGError: ERROR: value too long for type character varying(255)

Expected results:
User should be allowed to enter 255 char in name field and if it exceeds 255 char then UI should throw a clean validation error instead of PGError

Additional info:


Related issues

Related to Foreman - Bug #6694: PGError: while creating OS with long (greater than 5 chars) minor/major version valuesClosed2014-07-20
Related to Foreman - Bug #7437: PGError when host group title is exactly 256 charactersClosed2014-09-15
Related to Foreman - Refactor #7439: Host group name limited because lookup_value 'match' is a stringNew2014-09-15
Related to Foreman - Bug #7624: location and organization char names are capped to 246 instead of 255Closed2014-09-24

Associated revisions

Revision 5fbe760e (diff)
Added by Ori Rabin almost 5 years ago

Fixes #7038: No error when hostgroup name exceeds 245 characters

Revision 9b0b7bf6 (diff)
Added by Dominic Cleal over 4 years ago

refs #7038 - use n_() for plural support, use Rails style length message

History

#1 Updated by Dominic Cleal almost 5 years ago

  • Category set to Database
  • Priority changed from Low to Normal

Note that this isn't actually the host group name field causing the problem, it's the smart matchers (lookup_values).

#2 Updated by Ori Rabin almost 5 years ago

  • Related to Bug #6694: PGError: while creating OS with long (greater than 5 chars) minor/major version values added

#3 Updated by Ori Rabin almost 5 years ago

  • Status changed from New to Resolved
  • Assignee set to Ori Rabin

This was resolved when #6694 was fixed

#4 Updated by Dominic Cleal almost 5 years ago

Are you sure? I was able to reproduce the problem here on a nightly RPM installation. Note that it's the lookup_values causing the problem, not the name attribute of the hostgroup.

#5 Updated by Ori Rabin almost 5 years ago

  • Status changed from Resolved to Assigned

#6 Updated by The Foreman Bot almost 5 years ago

  • Status changed from Assigned to Ready For Testing
  • Target version set to 1.7.5
  • Pull request https://github.com/theforeman/foreman/pull/1686 added
  • Pull request deleted ()

#7 Updated by Ori Rabin almost 5 years ago

  • Pull request https://github.com/theforeman/foreman/pull/1701 added
  • Pull request deleted (https://github.com/theforeman/foreman/pull/1686)

#8 Updated by Dmitri Dolguikh almost 5 years ago

  • Target version changed from 1.7.5 to 1.7.4

#9 Updated by Dmitri Dolguikh almost 5 years ago

  • Target version changed from 1.7.4 to 1.7.3

#10 Updated by Ori Rabin almost 5 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

#11 Updated by Dominic Cleal almost 5 years ago

  • Legacy Backlogs Release (now unused) set to 21

#12 Updated by Dominic Cleal almost 5 years ago

  • Related to Bug #7437: PGError when host group title is exactly 256 characters added

#13 Updated by Ori Rabin almost 5 years ago

The error is a result of the lookup_value matchers that are created using the host title.
In the lookup_value table 'match' is a string column and I couldn't change it to text because there is an index on it.
Mysql doesn't really allow indexes on text columns, there is a workaround that didn't work for match.
To fix the error, the host name is now restricted so that it's title will not cause the matcher to be longer then 255 characters.
If there is a fix for the `match` attribute it will be a better fix to turn it into a text column and remove the restriction

#14 Updated by Ori Rabin almost 5 years ago

  • Related to Refactor #7439: Host group name limited because lookup_value 'match' is a string added

#15 Updated by Ori Rabin over 4 years ago

  • Related to Bug #7624: location and organization char names are capped to 246 instead of 255 added

Also available in: Atom PDF