fix(policy): harden resolve_model_name against non-str names#2573
fix(policy): harden resolve_model_name against non-str names#2573Bartok9 wants to merge 2 commits into
Conversation
Skip non-string to-match and catalog entries so corrupt MDL name sets cannot AttributeError on .lower() during table resolution.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Walkthrough
ChangesModel name resolution
Estimated code review effort: 2 (Simple) | ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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/policy.py (1)
162-165: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRemove the redundant collection-type branch.
Both branches construct
model_setwith the exact same comprehension, so theset/frozensetcheck provides no behavioral or performance benefit.Proposed simplification
- if isinstance(model_names, (set, frozenset)): - model_set = {n for n in model_names if isinstance(n, str) and n} - else: - model_set = {n for n in model_names if isinstance(n, str) and n} + model_set = {n for n in model_names if isinstance(n, str) and n}🤖 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/policy.py` around lines 162 - 165, Remove the redundant isinstance(model_names, (set, frozenset)) branch and define model_set once using the existing string-and-nonempty-name comprehension, preserving the current filtering behavior for all collection types.
🤖 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/policy.py`:
- Around line 162-165: Remove the redundant isinstance(model_names, (set,
frozenset)) branch and define model_set once using the existing
string-and-nonempty-name comprehension, preserving the current filtering
behavior for all collection types.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: f3597227-d865-4894-921b-08a40f9f7095
📒 Files selected for processing (2)
core/wren/src/wren/policy.pycore/wren/tests/unit/test_resolve_model_name_nonstr.py
|
Good catch — collapsed the redundant set/frozenset branch into a single comprehension in 26e80d8. Behavior unchanged. |
Summary
resolve_model_nameLicense
Apache-2.0 (
core/**).Motivation
Corrupt or partially-migrated MDL name collections could include
None/ints. Calling.lower()on those raised and aborted strict-mode planning even when a usable string candidate existed.Verification
cd core/wren && .venv/bin/python -m pytest tests/unit/test_resolve_model_name_nonstr.py -v— 3 passedDuplicate check
policy.resolve_model_namenon-str filteringSummary by CodeRabbit
Bug Fixes
Tests