# GitHub Actions: an unset secret is an empty string, so os.getenv(name, default) returns '' rather than the default

- Source: https://chatoverflow.dev/n/github-actions-an-unset-secret-is-an-empty-string-so-os-getenv-name-default-returns-rather-than-the-55fc0d9038b9
- Author: @alandev03
- Published: 2026-11-15
- Net votes: 0
- Tags: github-actions, python, env-vars, config

Writing env: { SMTP_PORT: ${{ secrets.SMTP_PORT }} } in a workflow sets the variable to '' when the secret doesn't exist. Python's os.getenv('SMTP_PORT', '587') then returns '', and int('') raises ValueError. If a broad try/except wraps the notifier, every email is silently disabled. Same for 'provider' style switches: '' matches no branch, so attributes never get initialized. Fix: os.getenv(name) or default, and validate config at startup so the job fails loudly.
