Skip to content

Fix Directory ledger entry dir_root validation#1008

Open
akshitj11 wants to merge 1 commit into
XRPLF:mainfrom
akshitj11:fix-885-directory-dir-root-optional
Open

Fix Directory ledger entry dir_root validation#1008
akshitj11 wants to merge 1 commit into
XRPLF:mainfrom
akshitj11:fix-885-directory-dir-root-optional

Conversation

@akshitj11

@akshitj11 akshitj11 commented Jun 19, 2026

Copy link
Copy Markdown

High Level Overview

Make Directory.dir_root optional in the ledger_entry request model so lookups by owner + sub_index work with the typed Python API.

Context of Change

Fixes #885. The XRPL server accepts directory lookups without dir_root, but xrpl-py rejected them at model validation time.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

Test plan

  • poetry run poe test tests/unit/models/requests/test_ledger_entry.py
  • poetry run poe lint

@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Directory.dir_root in xrpl/models/requests/ledger_entry.py is changed from a required field (str = REQUIRED) to an optional field (Optional[str] = None). A new test verifies that a LedgerEntry with a Directory using only owner and sub_index (no dir_root) passes validation.

Changes

Directory.dir_root optionality fix

Layer / File(s) Summary
Directory.dir_root made optional + test coverage
xrpl/models/requests/ledger_entry.py, tests/unit/models/requests/test_ledger_entry.py
dir_root is changed from str = REQUIRED to Optional[str] = None with an updated docstring. Directory is imported in the test module and a new test asserts that LedgerEntry(directory=Directory(owner=..., sub_index=0), ledger_index="validated") is valid.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

A rabbit once tripped on a field marked "required,"
But dir_root was optional — just poorly attired.
Now None by default, it hops free with delight,
With owner and sub_index both doing it right.
🐇✨ No more XRPLModelException in sight!

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The PR description covers the high-level overview, context of change, type of change, and test plan, but is missing the CHANGELOG.md update section. Add a clear indication of whether CHANGELOG.md was updated, following the template's 'Did you update CHANGELOG.md?' section with Yes/No and reasoning.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically identifies the main change: making the dir_root field optional in the Directory ledger entry request model.
Linked Issues check ✅ Passed The PR successfully addresses issue #885 by making dir_root optional in the Directory model and adding unit test coverage for owner+sub_index lookups, directly resolving the reported validation error.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing issue #885: modifying the Directory model's dir_root field and adding corresponding unit test coverage with no unrelated alterations.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Request model error xrpl.models.requests.ledger_entry.Directory

1 participant