Handle invalid data in COLUMNS env var when determining console width#9631
Handle invalid data in COLUMNS env var when determining console width#9631scollinson wants to merge 1 commit intoarmbian:mainfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughRefactored console width computation in Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@lib/tools/patching.py`:
- Around line 447-453: The computed console_width assignment can still be <= 0
when COLUMNS is numeric but small; update the block that sets console_width (the
variable computed in the if os.environ.get("GITHUB_ACTIONS", "") == "": branch)
to validate the parsed value after subtracting 12 and clamp it to a sensible
minimum (e.g., 40) or fall back to 160 if result <= 0; ensure you handle
ValueError as before and apply the same clamp/fallback in the GitHub Actions
else branch if desired.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: fa951d06-fcc1-4e2f-a2a6-0df8d2e8e383
📒 Files selected for processing (1)
lib/tools/patching.py
1d1e24d to
9600e5b
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@lib/tools/patching.py`:
- Around line 447-455: The indentation in the if-block checking
os.environ.get("GITHUB_ACTIONS") is mixed (tabs/spaces) and must be normalized
(use consistent spaces), and the logic around console_width needs adjusting: in
the block where you read COLUMNS (via os.environ.get("COLUMNS", "160")) parse it
inside a try/except to set console_width = int(...), fall back to 160 on
ValueError, then perform console_width -= 12 outside the try/except but still
inside the if that checks GITHUB_ACTIONS; reference the symbols console_width,
os.environ.get("COLUMNS", ...), and the GITHUB_ACTIONS check to locate and fix
the code.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: c0d4f627-fe34-4a8d-a677-7f97bef51df6
📒 Files selected for processing (1)
lib/tools/patching.py
9600e5b to
10075ad
Compare
10075ad to
79610ea
Compare
|
This reads as "force COLUMNS to at least 120" and "tolerate invalid COLUMNS values" (which will later be choked upon by unrelated utils). What is the underlying cause here? |
|
The underlying cause seems rather obvious from the backtrace, which is that somewhere in my buikd environment the variable COLUMNS is an empty string, causing an exception. I've not set this myself, and it also seems to happen in CI and my local host. The fix was pretty simple, but the AI review noted that should the COLUMNS value be less than 12 then the column width would be negative, which the current implementation does not account for either. If you can think of another sane default then I can replace 120. I've now spent more time writing this reponse than I did making the change, which seems like an obvious improvement and has meant my build pipeline now succeeds. |
Description
Building on the main branch gives me the following error:
How Has This Been Tested?
My build now completes, both locally and in CI.
Checklist:
Please delete options that are not relevant.
Summary by CodeRabbit