fix: return the mapped document type for an empty id - #974
Conversation
getDocument() short-circuits on an empty id before it looks the collection up, and returned a plain Document there even when the collection is mapped to a subclass with setDocumentType(). Every other empty result (missing row, denied read, negative cache) already comes back as the mapped class, so a caller relying on that class, such as an HTTP resource typed to return the current user or team, hit a TypeError only on the empty-id path. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthrough
ChangesMapped document instance handling
Priority: ⬇️ Low Estimated code review effort: 1 (Trivial) | ~5 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to The empty-document lookup preserves mapped document types while retaining the plain Document fallback for unmapped collections. The change is ready to merge. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Warning Git: CodeRabbit could not clone the repository, so clone-backed analysis was skipped and this review may be incomplete. Verify repository clone access, such as SSH credentials, before requesting another full review. If clone access is intentionally unavailable, use 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 |
|
getDocument()short-circuits on an empty id before it looks the collection up, and returned a plainDocumentthere even when the collection is mapped to a subclass withsetDocumentType(). Every other empty result (missing row, denied read, negative cache) already comes back as the mapped class, so a caller relying on that class, such as an HTTP resource typed to return the current user or team, hit aTypeErroronly on the empty-id path.Unit test added (
tests/unit/EmptyDocumentTypeTest.php, Memory adapters, no services); it fails onmainwithFailed asserting that an instance of class Utopia\Database\Document is an instance of class Tests\Unit\TypedUser.Lets appwrite-labs/cloud drop the per-request
new Project($doc->getArrayCopy())rebuild (appwrite-labs/cloud#5861).🤖 Generated with Claude Code
Summary by CodeRabbit