Skip to content
  • zzak's avatar
    1571041b
    Raise when using key which can't respond to `#to_sym` in EncryptedConfiguration · 1571041b
    zzak authored
    As is the case when trying to use an integer, float, or boolean as a key, which is unsupported.
    
    This replaces the following less-friendly error:
    
    ```
    NoMethodError: undefined method 'to_sym' for an instance of Integer
        lib/active_support/ordered_options.rb:38:in 'ActiveSupport::OrderedOptions#[]='
        lib/active_support/delegation.rb:167:in 'Kernel#public_send'
        lib/active_support/delegation.rb:167:in 'ActiveSupport::EncryptedConfiguration#method_missing'
    ```
    
    With a more helpful error message:
    
    ```
    ActiveSupport::EncryptedConfiguration::InvalidKeyError: Key '42' is invalid, it must respond to '#to_sym' from configuration in '/tmp/config-20240530-4153925-tfzzt/credentials.yml.enc'.
        lib/active_support/encrypted_configuration.rb:99:in 'block in ActiveSupport::EncryptedConfiguration#deep_symbolize_keys'
        lib/active_support/core_ext/hash/keys.rb:120:in 'block in Hash#_deep_transform_keys_in_object'
        lib/active_support/core_ext/hash/keys.rb:119:in 'Hash#each'
        lib/active_support/core_ext/hash/keys.rb:119:in 'Enumerable#each_with_object'
        lib/active_support/core_ext/hash/keys.rb:119:in 'Hash#_deep_transform_keys_in_object'
        lib/active_support/core_ext/hash/keys.rb:66:in 'Hash#deep_transform_keys'
        lib/active_support/encrypted_configuration.rb:96:in 'ActiveSupport::EncryptedConfiguration#deep_symbolize_keys'
        lib/active_support/encrypted_configuration.rb:86:in 'ActiveSupport::EncryptedConfiguration#config'
    ```
    1571041b
    Raise when using key which can't respond to `#to_sym` in EncryptedConfiguration
    zzak authored
    As is the case when trying to use an integer, float, or boolean as a key, which is unsupported.
    
    This replaces the following less-friendly error:
    
    ```
    NoMethodError: undefined method 'to_sym' for an instance of Integer
        lib/active_support/ordered_options.rb:38:in 'ActiveSupport::OrderedOptions#[]='
        lib/active_support/delegation.rb:167:in 'Kernel#public_send'
        lib/active_support/delegation.rb:167:in 'ActiveSupport::EncryptedConfiguration#method_missing'
    ```
    
    With a more helpful error message:
    
    ```
    ActiveSupport::EncryptedConfiguration::InvalidKeyError: Key '42' is invalid, it must respond to '#to_sym' from configuration in '/tmp/config-20240530-4153925-tfzzt/credentials.yml.enc'.
        lib/active_support/encrypted_configuration.rb:99:in 'block in ActiveSupport::EncryptedConfiguration#deep_symbolize_keys'
        lib/active_support/core_ext/hash/keys.rb:120:in 'block in Hash#_deep_transform_keys_in_object'
        lib/active_support/core_ext/hash/keys.rb:119:in 'Hash#each'
        lib/active_support/core_ext/hash/keys.rb:119:in 'Enumerable#each_with_object'
        lib/active_support/core_ext/hash/keys.rb:119:in 'Hash#_deep_transform_keys_in_object'
        lib/active_support/core_ext/hash/keys.rb:66:in 'Hash#deep_transform_keys'
        lib/active_support/encrypted_configuration.rb:96:in 'ActiveSupport::EncryptedConfiguration#deep_symbolize_keys'
        lib/active_support/encrypted_configuration.rb:86:in 'ActiveSupport::EncryptedConfiguration#config'
    ```
Loading