Bug #6914
closed
puppet class with numeric name can neither be edited nor deleted.
Added by Dominic Cleal over 10 years ago.
Updated over 6 years ago.
Description
Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=1126473
Description of problem:
Puppet class which contains names with numeric value can neither be edited nor deleted.
tail -f /var/log/foreman/production.log
Processing by PuppetclassesController#destroy as HTML
Parameters: {"authenticity_token"=>"LS/dL1pfhWqLRML7GMd72iCb8bN/ZAk1UaykFrtRlPY=", "id"=>"02197821"}
Rendered common/404.html.erb within layouts/application (2.7ms)
Rendered layouts/base.html.erb (3.2ms)
Completed 404 Not Found in 47ms (Views: 12.4ms | ActiveRecord: 3.9ms)
Version-Release number of selected component (if applicable):
sat6-GA-snap3
How reproducible:
always
Steps to Reproduce:
1.
2.
3.
Actual results:
puppet classes created with numeric values can neither be edited nor deleted.
Expected results:
puppet classes once created should be allowed to be edited and deleted.
Additional info:
- Related to Bug #6890: Puppet environment cannot be edited when name is only numeric added
- Category set to Web Interface
I would like to try and fix this (just for fun).
From the log, I have noticed a strange behavior.
If the name contains only numerical characters, ActiveRecord runs a query that looks for an id that matches.
Otherwise, it goes over the records' name attribute and compares.
I will try to figure out a nice way to fix this.
BR.
The log:
Started GET "/puppetclasses/123bla/edit" for 172.17.42.1 at 2014-08-25 19:37:46 +0000
Processing by PuppetclassesController#edit as HTML
Parameters: {"id"=>"123bla"}
Puppetclass Load (0.3ms) SELECT "puppetclasses".* FROM "puppetclasses" WHERE "puppetclasses"."name" = '123bla' ORDER BY puppetclasses.name LIMIT 1
Started GET "/puppetclasses/123/edit" for 172.17.42.1 at 2014-08-25 19:37:53 +0000
Processing by PuppetclassesController#edit as HTML
Parameters: {"id"=>"123"}
Puppetclass Load (0.1ms) SELECT "puppetclasses".* FROM "puppetclasses" WHERE "puppetclasses"."id" = ? ORDER BY puppetclasses.name LIMIT 1 "id", "123"
not found: Couldn't find Puppetclass with id=123
OK, I guess this is the reason for that behavior.
```
@puppetclass = (params[:id] =~ /\A\d+\Z/) ? pc.find(params[:id]) : pc.find_by_name(params[:id])
```
If the `params[:id]` is a number then we use `find`. Otherwise, we use `find_by_name`.
We probably should change this logic, to fix this bug.
BR.
- Status changed from New to Ready For Testing
- Target version set to 1.7.4
- Pull request https://github.com/theforeman/foreman/pull/1723 added
- Pull request deleted (
)
- Target version changed from 1.7.4 to 1.7.3
- Has duplicate Bug #7414: Can't delete class if contains special characters added
- Status changed from Ready For Testing to New
- Target version deleted (
1.7.3)
- Pull request added
- Pull request deleted (
https://github.com/theforeman/foreman/pull/1723)
upstream pull request has been closed.
- Status changed from New to Closed
- Target version set to 1.7.2
- Translation missing: en.field_release set to 21
- Related to Feature #4386: implement gem friendly_id to simply find by id, name, label, etc added
Also available in: Atom
PDF