Skip to content

Fix robyn.env parser crash on blank lines and truncation of '=' values - #1449

Open
eeshsaxena wants to merge 1 commit into
sparckles:mainfrom
eeshsaxena:fix/env-parser-blank-and-equals-1426
Open

eeshsaxena wants to merge 1 commit into
sparckles:mainfrom
eeshsaxena:fix/env-parser-blank-and-equals-1426

Conversation

@eeshsaxena

@eeshsaxena eeshsaxena commented Oct 2, 2026 •

Copy link
Copy Markdown

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, and load_vars() then indexes var[0]/var[1]. A blank or whitespace-only line yields [''] and a line with no = yields a one-element list, so load_vars hits var[1] and raises IndexError before the app even starts (it runs whenever a robyn.env exists, from cli.py and BaseRobyn.__init__). On top of that, split("=") with no maxsplit truncates any value that itself contains =, so a base64 secret like SECRET_KEY=abc=123== gets cut down to abc.

The fix strips each line, skips blanks, comments and lines without a usable key, and uses str.partition("=") so values keep their = characters. load_vars now only ever sees well-formed pairs. This is the version after the earlier CodeRabbit round on #1433 (empty-key lines like =value are rejected too, which avoids an os.environ[""] write).

Tests live in unit_tests/test_env_populator.py and cover the blank/whitespace/comment/valueless cases, =-in-value preservation, and a load_vars smoke test that would have crashed before the change. Importing the robyn package pulls in the compiled Rust extension, so I verified env_populator in isolation; the new tests are pure Python and don't need the extension. ruff and black are clean on both changed files.

Summary by CodeRabbit

  • Bug Fixes
    • Environment configuration files now correctly ignore blank lines and comments, skip malformed entries, and preserve additional = characters in values.
    • Valid settings after blank lines continue to load.

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
@vercel

vercel Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
robyn Error Error Oct 2, 2026 7:02am UTC

@coderabbitai

coderabbitai Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 73d95573-e0a5-4a39-8c2e-6d2a4c392574

📥 Commits

Reviewing files that changed from the base of the PR and between 1170748 and a836e95.

📒 Files selected for processing (2)
  • robyn/env_populator.py
  • unit_tests/test_env_populator.py

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The 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.

Changes

Environment file parsing

Layer / File(s) Summary
Parser behavior and load validation
robyn/env_populator.py, unit_tests/test_env_populator.py
The parser trims lines, skips blank lines, comments, and malformed entries, and splits assignments at the first equals sign. Tests cover these cases, values containing equals signs, and loading assignments around a blank line.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to a836e

The environment-file fixes appear ready to merge after normal checks.

Architecture Summary

Architecture risk: 🟡 Medium · up to a836e

The change affects 2 systems.

Changed systems: robyn, unit_tests

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — robyn (service) was modified; 1 changed file maps to changed impact.
  • observed — unit_tests (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in robyn/env_populator.py: parser now strips surrounding whitespace, ignores blank lines and comments, and splits each entry only at its first =. It logs and skips lines without a separator or with an empty key, replacing the prior behavior that split every line on = and only skipped lines beginning with #.
  • observed — Modified behavior in unit_tests/test_env_populator.py: Adds coverage that the parser ignores blank, whitespace-only, comment, malformed, and empty-key lines while returning valid assignments.
  • observed — Modified behavior in unit_tests/test_env_populator.py: Adds coverage that the parser preserves additional = characters in an assignment value.
  • observed — Modified behavior in unit_tests/test_env_populator.py: Adds coverage that load_vars loads assignments surrounding a blank line and restores the original ROBYN_PORT and ROBYN_HOST environment values in a finally block.

Reliability and maintainability

  • inferred — Risk-relevant change factors for robyn: blast_radius_3; direct_dependents_3
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies both primary fixes: preventing robyn.env parser crashes on malformed lines and preserving = characters in values.
Description check ✅ Passed The description explains the issue, implementation, scope, tests, and formatting checks. It does not follow the template headings or include the PR checklist and pre-commit confirmation, but the requi…
Linked Issues check ✅ Passed Issue #1426 requires blank and whitespace-only lines to be skipped, values containing = to be preserved, and malformed lines without a usable assignment to be ignored or reported. `robyn/env_populat…
Out of Scope Changes check ✅ Passed The changes are limited to the #1426 parser behavior and its regression tests. The added warning and empty-key handling support malformed-line handling within the issue scope. No unrelated implementat…
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

This branch had an error being deployed

1 failed deployment
Preview — a836e95e Deployed Oct 2, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

robyn.env parser crashes with IndexError on a blank line

1 participant