Project

General

Profile

Actions

Bug #6914

closed

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

Added by Dominic Cleal over 9 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Web Interface
Target version:
Difficulty:
Triaged:
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 3 (0 open3 closed)

Related to Foreman - Bug #6890: Puppet environment cannot be edited when name is only numericClosed08/01/2014Actions
Related to Foreman - Feature #4386: implement gem friendly_id to simply find by id, name, label, etcClosedJoseph Magen02/19/2014Actions
Has duplicate Foreman - Bug #7414: Can't delete class if contains special charactersDuplicate09/11/2014Actions
Actions #1

Updated by Dominic Cleal over 9 years ago

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

Updated by Dominic Cleal over 9 years ago

  • Category set to Web Interface
Actions #3

Updated by b sh over 9 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

Actions #4

Updated by b sh over 9 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.

Actions #5

Updated by The Foreman Bot over 9 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 ()
Actions #6

Updated by Anonymous over 9 years ago

  • Target version changed from 1.7.4 to 1.7.3
Actions #7

Updated by Dominic Cleal over 9 years ago

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

Updated by Ohad Levy over 9 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.

Actions #9

Updated by Dominic Cleal over 9 years ago

  • Status changed from New to Closed
  • Target version set to 1.7.2
  • translation missing: en.field_release set to 21

Fixed via #4386.

Actions #10

Updated by Dominic Cleal over 9 years ago

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

Also available in: Atom PDF