fix(connector): coerce non-string SQL in strip_trailing_semicolon#2539
fix(connector): coerce non-string SQL in strip_trailing_semicolon#2539Bartok9 wants to merge 1 commit into
Conversation
WalkthroughThe shared ChangesSemicolon Input Normalization
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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.
🧹 Nitpick comments (1)
core/wren/src/wren/connector/base.py (1)
19-27: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueUpdate the type hint to match the new behavior.
The function is now intentionally designed to accept
Noneand non-string values. However, the function signature on line 11 still typessqlasstr(def strip_trailing_semicolon(sql: str) -> str:). This will cause static type checkers to report errors when non-string arguments are passed to this function.Consider updating the type hint to
Any(e.g.,sql: Any) to accurately reflect this defensive behavior.# In core/wren/src/wren/connector/base.py, around line 11: from typing import Any def strip_trailing_semicolon(sql: Any) -> str:🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@core/wren/src/wren/connector/base.py` around lines 19 - 27, Update the `strip_trailing_semicolon` parameter annotation to accept the `None` and non-string values already handled by its implementation, importing `Any` from `typing` if needed, while keeping the return type as `str`.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@core/wren/src/wren/connector/base.py`:
- Around line 19-27: Update the `strip_trailing_semicolon` parameter annotation
to accept the `None` and non-string values already handled by its
implementation, importing `Any` from `typing` if needed, while keeping the
return type as `str`.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 0cafb939-d329-405d-9f5f-0343e307f5a4
📒 Files selected for processing (2)
core/wren/src/wren/connector/base.pycore/wren/tests/unit/test_strip_trailing_semicolon_coerce.py
Summary
sqlarguments instrip_trailing_semicolon(None→"", other values viastr(...)).TypeErrorinside the trailing-semicolon regex when callers pass accidental non-strings.Motivation
Every connector funnels user/limit/EXOLAIN composition through this helper. A
Noneor int SQL argument currently raisesTypeError: expected string or bytes-like objectdeep inre.sub, masking the real caller bug with a generic regex crash.License
Apache-2.0 path:
core/wren/src/wren/connector/base.py(+ unit test).Verification
cd core/wren && .venv/bin/python -m pytest tests/unit/test_strip_trailing_semicolon_coerce.py -q→ 3 passedTest plan
Summary by CodeRabbit
Bug Fixes
Tests