Skip to content

Boolean values taken from environment variables raise BadArguments #387

@amitlt

Description

@amitlt

Describe the bug
Some providers require boolean values to be supplied, like the tls option in the email provider.
If provided through environment variables, these values raise BadArguments exception.
Neither True, TRUE, true, yes or 1 work.

relevant error:

data = self._process_data(**kwargs)
  File "/Users/amitl/ops-lambdas/venv/lib/python3.7/site-packages/notifiers/core.py", line 235, in _process_data

    self._validate_data(data)
  File "/Users/amitl/ops-lambdas/venv/lib/python3.7/site-packages/notifiers/core.py", line 208, in _validate_data

    raise BadArguments(validation_error=msg, provider=self.name, data=data)
notifiers.exceptions.BadArguments: Error with sent data: 'true' is not of type 'boolean'

To Reproduce
Provide a boolean value through environment variables

NOTIFIERS_EMAIL_FROM="some@email.com"
NOTIFIERS_EMAIL_HOST="email-smtp.us-east-1.amazonaws.com"
NOTIFIERS_EMAIL_TLS=true
NOTIFIERS_EMAIL_USERNAME="USERNAME"
NOTIFIERS_EMAIL_PASSWORD="PASSWORD"

Expected behavior
For boolean values to be converted to booleans so they can pass schema check.

Additional context
Python version: 3.8
OS: macos

Metadata

Metadata

Assignees

Labels

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions