fix(context): harden relationships load + validate like views - #2613
fix(context): harden relationships load + validate like views#2613Bartok9 wants to merge 2 commits into
Conversation
|
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
ChangesRelationship YAML validation
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 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 |
|
The loader half here is right, but #2604 landed as 9bdae39 after this branch was opened and set the convention for exactly this situation — and this PR implements only half of it.
Measured on views.yml — reported (9bdae39): relationships.yml — silently gone: Same repo, same file type, same class of bad data, opposite user experience. What to do#2613 and #2607 are the two halves of one change and should be a single PR — the relationships counterpart of 9bdae39:
Note the ordering trap: with #2613's filter in place, That pair also makes #2606 ( RebaseThis branch is 17 commits behind |
Match 9bdae39 (Canner#2604): load_relationships drops non-dict entries; validate_project re-reads raw relationships.yml and reports malformed list/entries so hand-edits do not vanish silently.
0245eba to
f70dd32
Compare
|
Thanks @goldmedal — agreed on the #2604 pattern. Rebased onto current
Also closing #2607 as the incomplete reporting-only half, and #2606/#2608 as redundant consumer re-guards once this lands. |
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
core/wren/tests/unit/test_context.py (1)
1761-1766: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAssert the concrete type in the validation message.
The validation contract includes the offending type. This assertion only checks the prefix, so it would pass if
got strwere removed.Proposed test assertion
- assert any("'relationships' must be a list" in m for m in msgs) + assert any("'relationships' must be a list, got str" in m for m in msgs)🤖 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/tests/unit/test_context.py` around lines 1761 - 1766, Strengthen test_validate_project_reports_relationships_not_list by asserting the complete validation message includes both "'relationships' must be a list" and the offending type "got str", rather than checking only the message prefix.
🤖 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.
Inline comments:
In `@core/wren/tests/unit/test_context.py`:
- Line 10: Fix the import statement in test_context.py by moving
load_relationships and validate_project inside the parenthesized from
wren.context import list, preserving the existing imported symbols and valid
Python syntax.
---
Nitpick comments:
In `@core/wren/tests/unit/test_context.py`:
- Around line 1761-1766: Strengthen
test_validate_project_reports_relationships_not_list by asserting the complete
validation message includes both "'relationships' must be a list" and the
offending type "got str", rather than checking only the message prefix.
🪄 Autofix
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: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 61fcd03b-3ca1-4dde-9141-5e8da4ea159f
📒 Files selected for processing (2)
core/wren/src/wren/context.pycore/wren/tests/unit/test_context.py
Include load_relationships/validate_project inside the import paren list.
Summary
Relationships counterpart of 9bdae39 (#2604):
load_relationshipsfilters tolist[dict](drop non-mapping entries)validate_projectre-reads rawrelationships.ymland reports:'relationships' must be a list, got …relationship entry must be a mapping, got …Motivation
After #2604, views report hand-edited junk; relationships silently dropped it. Same class of bad data, opposite UX.
Note on siblings
This supersedes the split approach in #2607 (reporting half only / models-field only). Downstream consumer re-guards #2606/#2608 become unnecessary once context normalizes the contract — closing those as follow-through.
Verification
Summary by CodeRabbit