Project

General

Profile

Bug #22043

Unable to create location with organization_ids: [1] - Organizations is invalid

Added by Tomer Brisker almost 2 years ago. Updated over 1 year ago.

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

Description

During creation of a location, if it is assigned organizations which are invalid the creation fails as the location attempts to validate the associated organization. (This also happens the other way around). This is due to has_and_belongs_to_many defaulting to validating the associated records as well.

Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=1514915

Description of problem:

  1. curl -sku admin:changeme -d '{"location": {"name": "foo6", "organization_ids": [1]}}' -H 'Content-Type: application/json' https://$(hostname)/api/v2/locations {
    "error": {"id":null,"errors":{"organizations":["is invalid"]},"full_messages":["Organizations is invalid"]}
    }

- specifying other (existing) organization id(s) works as expected

Actual results:
Organizations is invalid

Expected results:
Location created and assigned to Default Organization

Associated revisions

Revision ad61b8ca (diff)
Added by Tomer Brisker almost 2 years ago

Fixes #22043 - Allow adding invalid orgs to locs (#5104)

And vice-versa. Currently when a taxonomy is invalid (e.g. because some
mismatch with hosts and resources), it cannot be assigned to the
opposite taxonomy. This is due to the fact that by default,
`has_and_belongs_to_many` associations validate the associated object as
well.

History

#1 Updated by The Foreman Bot almost 2 years ago

  • Assignee set to Tomer Brisker
  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/5104 added

#2 Updated by Marek Hulán almost 2 years ago

  • Legacy Backlogs Release (now unused) set to 296
  • Subject changed from Unable to create location with organization_ids: [1] - Organizations is invalid to Unable to create location with organization_ids: [1] - Organizations is invalid

#3 Updated by Anonymous almost 2 years ago

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

Also available in: Atom PDF