Project

General

Profile

Actions

Bug #16389

closed

Can't create taxable e.g. domain object if I'm in context of specific organization or location

Added by Marek Hulán almost 10 years ago. Updated about 8 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Organizations and Locations
Target version:
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

Steps to reproduce:
1) make sure you have organization, e.g. org A
2) switch to org A in context selector
3) go to domain
4) create a domain assigned to org A, this might still work
5) try to create new one again assigned to org A (should be preselected since you're in its context), it will stuck on the creation form displaying no errors and you can find "Failed to save: Taxable taxonomies is invalid" in log (if you have at least info level enabled)

to reproduce from console

# make sure there's at least one Domain in Organization.first
Organization.current = Organization.first
d = Domain.new :organization_ids => [1]
d.valid? # => false
d.taxable_taxonomies # return invalid taxable taxonomies linked to other (existing!) domain

Cause:
It seems that default scope added by taxonomies registers ids of existing records which gets picked by https://github.com/rails/rails/blob/v4.2.7.1/activerecord/lib/active_record/scoping/named.rb#L39:AR when it creates associations. A workaround is to do Domain.unscoped.new


Related issues 5 (1 open4 closed)

Related to OpenSCAP - Bug #16229: Invalid Taxable taxonomies when creating policy through UIClosedShlomi Zadok08/22/2016Actions
Related to Foreman - Tracker #10022: Taxonomies related issuesNew04/05/2015

Actions
Related to Foreman - Bug #4731: Creating domain when organization selected produces duplicate key errorClosedJoseph Magen03/19/2014Actions
Related to Foreman - Bug #16463: with_taxonomy_scope returns all objects when no taxable ids availableClosedDaniel Lobato Garcia09/07/2016Actions
Has duplicate Foreman - Bug #16471: Cannot create Host Group: Taxable taxonomies is invalidDuplicate09/07/2016Actions
Actions #1

Updated by Marek Hulán almost 10 years ago

  • Related to Bug #16229: Invalid Taxable taxonomies when creating policy through UI added
Actions #2

Updated by Marek Hulán almost 10 years ago

Actions #3

Updated by Marek Hulán almost 10 years ago

  • Related to Bug #4731: Creating domain when organization selected produces duplicate key error added
Actions #4

Updated by Marek Hulán almost 10 years ago

  • Status changed from New to Assigned
  • Assignee set to Marek Hulán
Actions #5

Updated by The Foreman Bot almost 10 years ago

  • Status changed from Assigned to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/3801 added
Actions #6

Updated by Marek Hulán almost 10 years ago

A proper fix should probably go to rails - https://github.com/rails/rails/pull/26342 but it's unrealistic to expect having this available anytime soon. Meanwhile, we can expand our existing hack to workaround it.

Actions #7

Updated by Marek Hulán almost 10 years ago

Since the upstream fix was declined, we have to solve it in Foreman. Probably less hacky way is to generate the part of SQL as a string so AREL can't parse it and register the condition for new instance, e.g.

Domain.where(id: 1).new.id # => 1
Domain.where('id IN (1)').new.id # => nil
Actions #8

Updated by Marek Hulán almost 10 years ago

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

Updated by Dominic Cleal almost 10 years ago

  • Translation missing: en.field_release set to 181
Actions #10

Updated by Marek Hulán almost 10 years ago

  • Target version set to 1.6.0
Actions #11

Updated by Dominic Cleal almost 10 years ago

  • Related to Bug #16463: with_taxonomy_scope returns all objects when no taxable ids available added
Actions #12

Updated by Dominic Cleal almost 10 years ago

  • Has duplicate Bug #16471: Cannot create Host Group: Taxable taxonomies is invalid added
Actions

Also available in: Atom PDF