From e3b52ed91dbdcee9915b114520d15ca1bc00c54c Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Mon, 25 Nov 2024 13:23:58 +0000 Subject: [PATCH 1/2] return nil for unknown setting whose format we cannot determine instead of throwing an error --- app/models/setting.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/models/setting.rb b/app/models/setting.rb index 654e24527512..4ee805e1410b 100644 --- a/app/models/setting.rb +++ b/app/models/setting.rb @@ -335,12 +335,14 @@ def self.settings_table_exists_yet? def self.deserialize(name, value) definition = Settings::Definition[name] - if definition.serialized? && value.is_a?(String) + if definition.nil? + nil + elsif definition.serialized? && value.is_a?(String) deserialize_hash(value) elsif value != "".freeze && !value.nil? read_formatted_setting(value, definition.format) - else - definition.format == :string ? value : nil + elsif definition.format == :string + value end end From f6e5727f38bfed13fb50b10dfbed2f8e2263852b Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Mon, 25 Nov 2024 13:28:22 +0000 Subject: [PATCH 2/2] prevent NoMethodError: undefined method `serialized?' for nil in tls option migration the 'ldap_tls_options' setting does no longer exist and has therefore no format de fined in the current code we also fixed the value/deserialize to handle this more gracefully, but for good measure we also just pick the value directly here because that is more robust --- db/migrate/20221115082403_add_ldap_tls_options.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/migrate/20221115082403_add_ldap_tls_options.rb b/db/migrate/20221115082403_add_ldap_tls_options.rb index 9ca761ec9526..898576e44727 100644 --- a/db/migrate/20221115082403_add_ldap_tls_options.rb +++ b/db/migrate/20221115082403_add_ldap_tls_options.rb @@ -42,7 +42,7 @@ def change # Current LDAP library default is to not verify the certificate MigratingAuthSource.reset_column_information - ldap_settings = Setting.find_by(name: "ldap_tls_options")&.value + ldap_settings = Setting.where(name: "ldap_tls_options").pick :value migrate_ldap_settings(ldap_settings) end end