Skip to content

Fix crash on empty values - #43

Open
m-rinaldi wants to merge 1 commit into
nsaunders:masterfrom
m-rinaldi:fix/empty-values
Open

m-rinaldi wants to merge 1 commit into
nsaunders:masterfrom
m-rinaldi:fix/empty-values

Conversation

@m-rinaldi

Copy link
Copy Markdown

Fix crash on empty values

A setting with an empty value makes loadFile throw, so the application never starts.

Minimal example for reproducing it

.env:

OPTIONAL_SETTING=

Main.purs:

main = launchAff_ do
  Dotenv.loadFile
  liftEffect $ log "Loaded successfully."

Crashes with:

Error: Expected variable value

The same happens for OPTIONAL_SETTING="" and OPTIONAL_SETTING='', anywhere in the file.

Cause

The value parser requires at least one piece (some), so an empty value never matches.

Fix

Allows zero pieces (many) in quoted and unquoted values, and maps an empty value to LiteralValue "". Empty values now resolve to the empty string.

Also adds a parser test for A=.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant