Bug #16657
closedNo validation for Discovery Rule name
Added by Swapnil Abnave about 8 years ago. Updated about 8 years ago.
Description
Description of problem:
Discovery Rule with name that is longer than 255 characters should not be created.
Actual results:
Discovery rule is created successfully
Expected results:
Error message ("is too long (maximum is 255 characters)") should be displayed
Updated by Swapnil Abnave about 8 years ago
`discovery_rules` table description from discovery_plugin version 5.0.0.9
Table "public.discovery_rules"
Column | Type | Modifiers | Storage | Stats target | Description
--------------+-----------------------------+--------------------------------------------------------------+----------+--------------+-------------
id | integer | not null default nextval('discovery_rules_id_seq'::regclass) | plain | |
name | character varying(255) | | extended | |
search | character varying(255) | | extended | |
hostgroup_id | integer | not null | plain | |
hostname | character varying(255) | default ''::character varying | extended | |
max_count | integer | default 0 | plain | |
priority | integer | default 0 | plain | |
enabled | boolean | not null default true | plain | |
created_at | timestamp without time zone | | plain | |
updated_at | timestamp without time zone | | plain | |
Indexes:
"discovery_rules_pkey" PRIMARY KEY, btree (id)
Has OIDs: no
Latest table description for `discovery_rules`
katello=# \d+ discovery_rules
Table "public.discovery_rules"
Column | Type | Modifiers | Storage | Stats target | Description
--------------+-----------------------------+--------------------------------------------------------------+----------+--------------+-------------
id | integer | not null default nextval('discovery_rules_id_seq'::regclass) | plain | |
name | character varying | | extended | |
search | character varying | | extended | |
hostgroup_id | integer | not null | plain | |
hostname | character varying | default ''::character varying | extended | |
max_count | integer | default 0 | plain | |
priority | integer | default 0 | plain | |
enabled | boolean | not null default true | plain | |
created_at | timestamp without time zone | | plain | |
updated_at | timestamp without time zone | | plain | |
Indexes:
"discovery_rules_pkey" PRIMARY KEY, btree (id)
Has OIDs: no
As you can see the limits for columns name,search, hostname have been dropped in latest version. This is causing [validates_lengths_from_database[https://github.com/theforeman/foreman_discovery/blob/develop/app/models/discovery_rule.rb#L16]] to have no effect on length validation of model `DiscoveryRule`.
I am working on finding the reason the reason. But not able to get it, does anyone have idea about it ?
I searched in foreman, foreman_discovery plugins.. no luck.
Updated by Dominic Cleal about 8 years ago
- Translation missing: en.field_release deleted (
189)
Updated by Dominic Cleal about 8 years ago
The default string length changed in 1.12: http://projects.theforeman.org/projects/foreman/wiki/Rails_42#String-limits
Updated by Swapnil Abnave about 8 years ago
Dominic Cleal wrote:
The default string length changed in 1.12: http://projects.theforeman.org/projects/foreman/wiki/Rails_42#String-limits
Ahh... Thanks Dominic. I wasn't knowing that.
To some extent, it makes sense : https://github.com/rails/rails/pull/14579
Do you think that adding limit would take performance hit in this scenario(of discovery_rule).
Updated by Swapnil Abnave about 8 years ago
Pull request : https://github.com/theforeman/foreman_discovery/pull/302
Updated by The Foreman Bot about 8 years ago
- Status changed from New to Ready For Testing
- Pull request https://github.com/theforeman/foreman_discovery/pull/302 added
Updated by Swapnil Abnave about 8 years ago
- Status changed from Ready For Testing to Closed
- % Done changed from 0 to 100
Applied in changeset foreman_discovery|da484659e8ea5bebbc0c933f32b369a75c2d04bf.