lukewhrit / spacebin

🔭 spacebin: text sharing for the final frontier

Home Page:https://spaceb.in

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

bug: Environment variable parsing for Config doesn't work with `_` delimited fields.

lukewhrit opened this issue · comments

commented

Describe the bug

When providing an environment variable for a field with a name that contains underscore characters the environment variable parser incorrectly understands them as field hierarchy separators to be transformed, instead of characters used in the name of a field to be preserved.

To Reproduce

Steps to reproduce the behavior (What were you doing at the time?):

  1. Pass an environment variable such as SPACEBIN_DOCUMENTS_ID_LENGTH above or below the default of 12.
  2. Start the instance.
  3. Create a document of any value, shape, or size on the instance.
  4. Observe an ID length of 12 in the document URL.

Expected behavior

If the parser were designed correctly, it would realize that field name's that contain an underscore and parse them correctly.

By correctly, I mean that the name would be preserved but the hierarchy still be maintained.

Screenshots

N/A

Additional context

N/A

commented

The most likely to be implemented solution for this is to remove support for TOML configuration files and use https://github.com/caarlos0/env for parsing environment variables into the config struct and going from there