Repository navigation
Fix robyn.env parser crash on blank lines and truncation of '=' values - #1449
eeshsaxena wants to merge 1 commit into
Conversation
parser() split every non-comment line on '=' and yielded it unconditionally,
so a blank line or a line without '=' produced a short list and load_vars
hit an IndexError before the app could start. Splitting without maxsplit also
truncated values that themselves contain '=' (e.g. base64 secrets).
Strip each line, skip blanks/comments and lines without a key, and use
str.partition('=') so values keep their '=' characters.
Fixes sparckles#1426
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe environment parser now skips blank, comment, and malformed lines. It splits valid assignments at the first equals sign, preserving any additional equals signs in the value. Tests cover parsing and variable loading around a blank line. ChangesEnvironment file parsing
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~8 minutes Change: Bug fix · Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to The environment-file fixes appear ready to merge after normal checks. Architecture SummaryArchitecture risk: 🟡 Medium · up to The change affects 2 systems. Changed systems: Architecture concerns Review detailsSystems and components
Before / after behavior
Reliability and maintainability
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This reopens #1433. You asked me to bring it back ("could you please reopen this? This is still very much relevant"), but I'd deleted the original branch while tidying up my backlog and GitHub won't let a PR be reopened once its branch is gone, so this is the same change on a fresh branch off current
main.Fixes #1426.
The problem is in
robyn/env_populator.py.parser()splits every non-comment line on=and yields the result unconditionally, andload_vars()then indexesvar[0]/var[1]. A blank or whitespace-only line yields['']and a line with no=yields a one-element list, soload_varshitsvar[1]and raisesIndexErrorbefore the app even starts (it runs whenever arobyn.envexists, fromcli.pyandBaseRobyn.__init__). On top of that,split("=")with nomaxsplittruncates any value that itself contains=, so a base64 secret likeSECRET_KEY=abc=123==gets cut down toabc.The fix strips each line, skips blanks, comments and lines without a usable key, and uses
str.partition("=")so values keep their=characters.load_varsnow only ever sees well-formed pairs. This is the version after the earlier CodeRabbit round on #1433 (empty-key lines like=valueare rejected too, which avoids anos.environ[""]write).Tests live in
unit_tests/test_env_populator.pyand cover the blank/whitespace/comment/valueless cases,=-in-value preservation, and aload_varssmoke test that would have crashed before the change. Importing therobynpackage pulls in the compiled Rust extension, so I verifiedenv_populatorin isolation; the new tests are pure Python and don't need the extension.ruffandblackare clean on both changed files.Summary by CodeRabbit
=characters in values.