fix: make Directory.dir_root and Directory.owner optional in LedgerEntry#943
fix: make Directory.dir_root and Directory.owner optional in LedgerEntry#943m1lestones wants to merge 1 commit intoXRPLF:mainfrom
Conversation
Both `dir_root` and `owner` were marked as REQUIRED in the Directory model, but the XRPL ledger_entry API only requires one of the two. This caused a spurious XRPLModelException when constructing a Directory with only `owner` (a valid and commonly used pattern). - Make both `owner` and `dir_root` Optional[str] = None - Add _get_errors validation ensuring at least one is provided - Add regression tests covering owner-only, dir_root-only, and neither-provided cases Fixes XRPLF#885
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughThe Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
Description
Fixes #885.
Both
dir_rootandownerwere marked asREQUIREDin theDirectorymodel used byLedgerEntry, but the XRPLledger_entrydocs specify that only one of the two is needed — you can look up a DirectoryNode byowneralone or bydir_rootalone.This caused a spurious
XRPLModelException: {'dir_root': 'dir_root is not set'}when constructing a validDirectorywith onlyownerprovided, even though the same query works correctly when passed as a raw dict.Changes
xrpl/models/requests/ledger_entry.pyDirectory.owner:str = REQUIRED→Optional[str] = NoneDirectory.dir_root:str = REQUIRED→Optional[str] = NoneDirectory._get_errors()to enforce that at least one ofownerordir_rootis providedtests/unit/models/requests/test_ledger_entry.pyDirectoryto importstest_directory_with_owner_only_is_valid— regression test for Request model error xrpl.models.requests.ledger_entry.Directory #885test_directory_with_dir_root_only_is_valid— confirms dir_root-only is also validtest_directory_with_neither_owner_nor_dir_root_is_invalid— confirms validation catches missing fieldsTest plan
test_directory_with_owner_only_is_valid— the exact case from issue Request model error xrpl.models.requests.ledger_entry.Directory #885 now passestest_directory_with_dir_root_only_is_valid— dir_root-only lookup is validtest_directory_with_neither_owner_nor_dir_root_is_invalid— raises XRPLModelException as expectedTestLedgerEntrytests continue to pass