Project

General

Profile

Actions

Refactor #34569

closed

Postpone LookupValue match validations

Added by Ondřej Ezr about 2 years ago. Updated about 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Rails
Target version:
-
Difficulty:
Triaged:
No
Fixed in Releases:
Found in Releases:

Description

match gets overriden by Rails if the record has been build by association e.g. `host.lookup_values.build()`
That basically means that any assigned value to match prior save is irrelevant because it will be replaced by Rails.

This was never an issue, because Rails just replaced the value with the same value as we've assigned, so it went unnoticed.
It only starts to cause issues once Rails had fixed a bug where it wrongly allowed foreign_key to be passed to <assoc>.build(foreign_key => value)
This is for sym vs string in hash keys as in https://github.com/rails/rails/blob/13cdd7a6aef86b23c3410adff1d4f6eeefc72c67/activerecord/lib/active_record/associations/association.rb#L196 reflection.foreign_key returned a symbol, but attribute is a string, so the assigned foreign key did not get filtered out properly.

This bug had been fixed in Rails 6.1 and the assigned foreign key is filtered out properly and our validations fail on presence of match as that gets assigned from host only after the Host is saved and thats after validation.


Related issues 1 (1 open0 closed)

Blocks Foreman - Tracker #28570: Rails 6.1 TrackerNew

Actions
Actions #1

Updated by The Foreman Bot about 2 years ago

  • Status changed from New to Ready For Testing
  • Assignee set to Ondřej Ezr
  • Pull request https://github.com/theforeman/foreman/pull/9137 added
Actions #2

Updated by Ondřej Ezr about 2 years ago

  • Parent task set to #28570
Actions #3

Updated by Ondřej Ezr about 2 years ago

  • Parent task deleted (#28570)
Actions #4

Updated by Ondřej Ezr about 2 years ago

Actions #5

Updated by The Foreman Bot about 2 years ago

  • Fixed in Releases 3.3.0 added
Actions #6

Updated by Ondřej Ezr about 2 years ago

  • Status changed from Ready For Testing to Closed
Actions

Also available in: Atom PDF