Ignore invalid environment variables

This commit is contained in:
2025-08-17 15:36:07 +01:00
parent d00a4048cd
commit dc445bcc66

View File

@@ -49,7 +49,11 @@ def main():
# Override with environment variables, named SMSBOT_<SECTION>_<VALUE>
for key, value in os.environ.items():
if key.startswith(ENVIRONMENT_PREFIX):
try:
section, option = key[7:].lower().split("_", 1)
except ValueError:
logging.debug("Invalid environment variable format: %s", key)
continue
logging.debug("Overriding config %s/%s = %s", section, option, value)
if not config.has_section(section):
config.add_section(section)