fix(colang): raise ValueError for unbalanced closing bracket in split_args#2145
Open
vidigoat wants to merge 1 commit into
Open
fix(colang): raise ValueError for unbalanced closing bracket in split_args#2145vidigoat wants to merge 1 commit into
vidigoat wants to merge 1 commit into
Conversation
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe Changessplit_args bracket validation fix
Estimated code review effort: 1 (Trivial) | ~5 minutes 🚥 Pre-merge checks | ✅ 6✅ Passed checks (6 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
⚔️ Resolve merge conflicts
Comment |
…_args split_args read closing_char[stack[-1]] for every closing character, but when a ) ] or } appeared with an empty bracket stack, stack[-1] raised an uncaught IndexError. Quote characters are unaffected (they are treated as openers on an empty stack). This adds an explicit empty-stack guard that raises the same ValueError the function already uses to report malformed input, so callers get a consistent, catchable error instead of an IndexError. Signed-off-by: Vidit Patankar <vidit.patankar16@gmail.com>
d78589e to
0d5c246
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2144
Description
split_argsreadsclosing_char[stack[-1]]for every closing character, but when a),], or}appears with an empty bracket stack,stack[-1]raises an uncaughtIndexError. (Quote characters are unaffected — they are treated as openers on an empty stack.) This adds an explicit empty-stack guard that raises the sameValueErrorthe function already uses to report malformed input, so callers get a consistent, catchable error instead of anIndexError.Steps to reproduce (before this fix)
Also affected:
")","a)b","foo]","}".Test plan
tests/test_parser_utils.pycovering")","a)b","foo]","x=1, y)","}"; each now assertsValueError.IndexError) and passes after; existingsplit_argstests and the mismatched-bracketValueErrorpath are unchanged.AI disclosure
This change was drafted with the assistance of an AI coding assistant; I reproduced the bug and verified the fix and tests before submitting.
Summary by CodeRabbit