Project

General

Profile

Bug #21168

Can't create a location

Added by Ori Rabin about 4 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
High
Assignee:
Category:
-
Difficulty:
Triaged:
Bugzilla link:

Description

Trying to create a location silently fails, the server log only shows: "Failed to save: "
In the taxonomy controller using save! instead of save gives: ActiveRecord::RecordInvalid: Validation failed: Taxonomy has already been taken.

The sql logs show this insert right before rollback:

2017-10-02T16:41:58 471cb7ee [sql] [D]   SQL (0.6ms)  INSERT INTO "taxable_taxonomies" ("taxonomy_id", "taxable_id", "taxable_type", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id"  [["taxonomy_id", 23], ["taxable_id", 104], ["taxable_type", "JobTemplate"], ["created_at", "2017-10-02 13:41:58.701252"], ["updated_at", "2017-10-02 13:41:58.701252"]]
2017-10-02T16:41:58 471cb7ee [sql] [D]   TaxableTaxonomy Exists (0.9ms)  SELECT  1 AS one FROM "taxable_taxonomies" WHERE "taxable_taxonomies"."taxonomy_id" = $1 AND "taxable_taxonomies"."taxable_id" = $2 AND "taxable_taxonomies"."taxable_type" = $3 LIMIT $4  [["taxonomy_id", 23], ["taxable_id", 100], ["taxable_type", "JobTemplate"], ["LIMIT", 1]]
2017-10-02T16:41:59 471cb7ee [sql] [D]    (0.4ms)  ROLLBACK

After deleting all of the job templates (including the seeded ones) the location can be saved.


Related issues

Related to Foreman Remote Execution - Bug #20427: REX doesnt start with rails 5Closed2017-07-27
Related to Foreman Remote Execution - Bug #11805: error creating organization in assign_default_templatesClosed2015-09-14
Blocked by Foreman - Bug #11825: Adding template types from plugins doesn't work with taxonomiesClosed2015-09-15

Associated revisions

Revision 806f03af (diff)
Added by Ivan Necas about 4 years ago

Fixes #21168 - Workaround for rails5 callbacks (#277)

Revision afb7a4a3 (diff)
Added by Ivan Necas about 4 years ago

Refs #21168 - raise => false only for Rails 5 (#284)

Rails 4 doesn't raise any issue when callback is not found and it
doesn't even know the raise option. Due to this, it considers the
additional option being a sign of need for re-definition of the
original callback, instead of just making it as skipped.

This patch sets the `raise => false` only for Rails 5, where it's
needed.

History

#1 Updated by Adam Ruzicka about 4 years ago

While trying to reproduce this I encountered a possibly related error

pry(main)> loc.save!
ActiveRecord::InvalidForeignKey: PG::ForeignKeyViolation: ERROR:  insert or update on table "taxable_taxonomies" violates foreign key constraint "taxable_taxonomies_taxonomy_id_fk" 
DETAIL:  Key (taxonomy_id)=(5) is not present in table "taxonomies".
: INSERT INTO "taxable_taxonomies" ("taxonomy_id", "taxable_id", "taxable_type", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" 
from /home/aruzicka/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/activerecord-5.0.6/lib/active_record/connection_adapters/postgresql_adapter.rb:598:in `async_exec'

#2 Updated by Ivan Necas about 4 years ago

  • Priority changed from Normal to High

#3 Updated by Adam Ruzicka about 4 years ago

  • Related to Bug #20427: REX doesnt start with rails 5 added

#4 Updated by Ivan Necas about 4 years ago

  • Related to Bug #11805: error creating organization in assign_default_templates added

#5 Updated by Ivan Necas about 4 years ago

  • Blocked by Bug #11825: Adding template types from plugins doesn't work with taxonomies added

#6 Updated by The Foreman Bot about 4 years ago

  • Status changed from New to Ready For Testing
  • Assignee set to Ivan Necas
  • Pull request https://github.com/theforeman/foreman_remote_execution/pull/277 added

#7 Updated by Ivan Necas about 4 years ago

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

#8 Updated by The Foreman Bot about 4 years ago

  • Pull request https://github.com/theforeman/foreman_remote_execution/pull/284 added

#9 Updated by Ivan Necas about 4 years ago

  • Legacy Backlogs Release (now unused) set to 321

Also available in: Atom PDF