Project

General

Profile

Bug #6914

puppet class with numeric name can neither be edited nor deleted.

Added by Dominic Cleal about 5 years ago. Updated about 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Web Interface
Target version:
Difficulty:
Triaged:
Bugzilla link:
Pull request:
Team Backlog:
Fixed in Releases:
Found in Releases:

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 issues

Related to Foreman - Bug #6890: Puppet environment cannot be edited when name is only numericClosed2014-08-01
Related to Foreman - Feature #4386: implement gem friendly_id to simply find by id, name, label, etcClosed2014-02-19
Has duplicate Foreman - Bug #7414: Can't delete class if contains special charactersDuplicate2014-09-11

History

#1 Updated by Dominic Cleal about 5 years ago

  • Related to Bug #6890: Puppet environment cannot be edited when name is only numeric added

#2 Updated by Dominic Cleal about 5 years ago

  • Category set to Web Interface

#3 Updated by b sh almost 5 years ago

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

#4 Updated by b sh almost 5 years ago

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.

#5 Updated by The Foreman Bot almost 5 years ago

  • 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 ()

#6 Updated by Dmitri Dolguikh almost 5 years ago

  • Target version changed from 1.7.4 to 1.7.3

#7 Updated by Dominic Cleal almost 5 years ago

  • Has duplicate Bug #7414: Can't delete class if contains special characters added

#8 Updated by Ohad Levy almost 5 years ago

  • 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.

#9 Updated by Dominic Cleal almost 5 years ago

  • Status changed from New to Closed
  • Target version set to 1.7.2
  • Legacy Backlogs Release (now unused) set to 21

Fixed via #4386.

#10 Updated by Dominic Cleal almost 5 years ago

  • Related to Feature #4386: implement gem friendly_id to simply find by id, name, label, etc added

Also available in: Atom PDF