Project

General

Profile

Bug #24935

belongs_to_proxy doesn't validate :required option

Added by Stephen Benjamin 3 months ago. Updated 3 months ago.

Status:
Closed
Priority:
Normal
Category:
Smart proxies
Target version:
-
Difficulty:
Triaged:
No
Bugzilla link:
Team Backlog:
Fixed in Releases:
Found in Releases:

Description

belongs_to_proxy ignores the `required` option, so you can set invalid proxy ID's, which ends up hitting database constraints. For example:

$ hammer -u admin -p changeme realm create --name Potato --realm-proxy-id '941' --realm-type FreeIPA
Could not create the realm:
  PG::ForeignKeyViolation: ERROR:  insert or update on table "realms" violates foreign key constraint "realms_realm_proxy_id_fk" 
  DETAIL:  Key (realm_proxy_id)=(941) is not present in table "smart_proxies".
  : INSERT INTO "realms" ("name", "realm_type", "realm_proxy_id", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" 

Whereas it should say something like this:

$ hammer -u admin -p changeme realm create --name Potato --realm-proxy-id '941' --realm-type FreeIPA
Could not create the realm:
  Realm proxy was not found

Associated revisions

Revision 75d02d8e (diff)
Added by Stephen Benjamin 3 months ago

fixes #24935 - validate existence of proxy assocations

History

#1 Updated by Stephen Benjamin 3 months ago

  • Bugzilla link set to 1599322

#2 Updated by The Foreman Bot 3 months ago

  • Assignee set to Stephen Benjamin
  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/6064 added

#3 Updated by Timo Goebel 3 months ago

  • Fixed in Releases 1.20.0 added

#4 Updated by Stephen Benjamin 3 months ago

  • Status changed from Ready For Testing to Closed

Also available in: Atom PDF