Skip to content

Providing an improperly formatted dotenv file silently passes #94

@cmmorrow

Description

@cmmorrow

Describe the bug
If using the --dotenv option from the command-line or dotenv: in a Config File and providing a file that is not a dotenv file doesn't cause an error. It would be better to let the user know that they provided an improperly formatted instead of continuing with executing commands and potentially failing later.

To Reproduce
Steps to reproduce the behavior:

  1. Run build-magic --dotenv [some file] echo hello where [some file] is any file that isn't a dotenv file.

Expected behavior
An improperly formatted dotenv file should raise an error and communicate the impropriety to the user.

Additional context
The dotenv file is read and parsed in cli/parse_dotenv_file() and the logic simply continues to the next line if it doesn't contain an "=":

envs = {}
    for line in dotenv.readlines():
        if line.startswith('#'):
            continue
        if '=' not in line:
            continue
        env, val = line.split('=', maxsplit=1)
        envs.update({env.strip(): val.strip()})

The checks inside this loop should be replaced with a single step that validates the dotenv file.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinggood first issueGood for newcomershelp wantedExtra attention is needed

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions