robyn.env parser crashes with IndexError on a blank line
Bug Description
robyn/env_populator.py's parser() splits every non-comment line in robyn.env on = and yields the result unconditionally, and load_vars() unconditionally indexes var[0]/var[1]:
https://github.com/sparckles/Robyn/blob/main/robyn/env_populator.py#L17-L34
for line in f:
if line.startswith("#"):
continue
yield line.strip().split("=")
...
for var in variables:
if var[0] in os.environ:
...
else:
os.environ[var[0]] = var[1]A blank line (or a line that's just whitespace/a newline) produces "".split("=") → [''], a one-element list. load_vars then does var[1] → IndexError: list index out of range, crashing the app before it even starts — load_vars() runs unconditionally from robyn/cli.py (and from BaseRobyn.__init__ when not run via the CLI) whenever a robyn.env file exists.
A related, quieter bug on the same line: split("=") has no maxsplit, so any value that itself contains = (e.g. a base64 secret like SECRET_KEY=abc=123==) gets truncated — var[1] becomes just "abc" instead of "abc=123==".
Steps to Reproduce
import tempfile, os
from pathlib import Path
from robyn.env_populator import load_vars
d = tempfile.mkdtemp()
Path(d, "robyn.env").write_text("ROBYN_PORT=8080\n\nROBYN_HOST=127.0.0.1\n") # note the blank line
load_vars(project_root=d)Traceback (most recent call last):
...
IndexError: list index out of rangeReproduced directly against current main.
Expected vs Actual
- Expected: blank lines in
robyn.envare silently skipped (as#-comment lines already are), and values containing=are preserved in full. - Actual: a blank line crashes app startup with an unhandled
IndexError; values containing=are silently truncated.
Suggested Fix
for line in f:
line = line.strip()
if not line or line.startswith("#"):
continue
if "=" not in line:
continue # or log a warning about a malformed line
yield line.split("=", 1) # maxsplit=1 preserves '=' inside the valueAdditional Info
unit_tests/test_env_populator.py only covers a well-formed two-line file, so this path currently has no regression coverage. Found via a broader codebase audit while working on #485 (response compression). Robyn version: main branch.
Source: sparckles/Robyn