fix(transaction): guard version parsing against short version strings#994
fix(transaction): guard version parsing against short version strings#994CodeLine9 wants to merge 1 commit intoXRPLF:mainfrom
Conversation
WalkthroughThe Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@xrpl/asyncio/transaction/main.py`:
- Around line 346-347: Add unit tests for _is_not_later_rippled_version and its
caller _tx_needs_networkID to cover malformed version strings so the existing
guard (if len(source_decomp) < 3 or len(target_decomp) < 3: return False) is
exercised: include cases like source="1.11" vs target="1.11.0", both sides
shorter than three segments, and assert that no IndexError is raised and that
the function returns False (the caller then skips adding network_id). Put tests
that explicitly pass malformed inputs into _is_not_later_rippled_version and
through _tx_needs_networkID to confirm behavior; optionally add a comment in the
tests noting the semantic caveat about "unknown" vs "not later" for future
maintainers.
🪄 Autofix (Beta)
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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 3cf59104-11d9-4572-8cf7-eb85e6831b89
📒 Files selected for processing (1)
xrpl/asyncio/transaction/main.py
Bug
_is_not_later_rippled_version()splits the version on.and directly accesses indices[0],[1],[2]. A 2-part version string (e.g."1.11") from a buggy or compromised server causes anIndexError.Fix
Check that both decomposed version strings have at least 3 parts before accessing them. If not, return
False(treat as unknown version).Closes #975