palkan/anyway_config

A string containing comas is splited despite being put into quotas

Closed this issue · 2 comments

pk65 commented

What did you do?

I want such config in config/settings/ldap.yml

default: &default
  :encryption: :simple_tls
  :port: 636
  :host: ldaps.example.com
  :auth_method: :simple
  :auth_username: "CN=dummy-user,DC=example,DC=com"
  :auth_password: "dummy,password"

development:
  <<: *default

test:
  <<: *default

What did you expect to happen?

LdapConfig.auth_username and LdapConfig.auth_password should give a strings

What actually happened?

LdapConfig.auth_username and LdapConfig.auth_password give a arrays of elements from the string splitted by coma.

Additional context

Upgrading to Anyway Config 2.6.2 doesn't help.
The same happens when username and password are assigned via environment variables.

Environment

Ruby Version: 3.2.2

Framework Version (Rails, whatever): Rails 7.0.8

Anyway Config Version: 2.5.4

We perform automatic type casting of string values to handle data sources which only support strings (such as env). If you expect comma separated strings and want to treat them as string, you can explicitly declare such params as strings (see docs):

coerce_types auth_username: :string, auth_password: :string

That should help.

pk65 commented