Skip to content

Conversation

@mvadari
Copy link
Collaborator

@mvadari mvadari commented Oct 29, 2025

High Level Overview of Change

Fix the definitions generation script so that it better handles formatting changes, like adding new lines

Context of Change

Some newlines were introduced in transactions.macro, which weren't properly captured by the regex

Type of Change

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

Did you update CHANGELOG.md?

  • No, this change does not impact library users

Test Plan

Works locally.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 29, 2025

Walkthrough

Broadened multiple parser regexes to accept optional spaces/newlines between tokens and updated binary codec definitions JSON by adding Int32/Int64 types and two new fields, removing one transaction result key, and reordering some transaction type entries.

Changes

Cohort / File(s) Summary
Parser regex relaxations
tools/generate_definitions.py
Broadened several regex patterns (STYPE, TYPED_SFIELD, LEDGER_ENTRY, TER parsing, TRANSACTION) to permit optional whitespace (spaces/newlines) between tokens and separators while preserving captured groups and output shape.
Binary codec definitions updates
xrpl/core/binarycodec/definitions/definitions.json
Added new field entries MutableFlags and DummyInt32; introduced Int32 and Int64 types; removed tedADDRESS_COLLISION from TRANSACTION_RESULTS; resequenced TRANSACTION_TYPES entries (VaultCreate/VaultDeposit) and added Int32/Int64 references.

Sequence Diagram(s)

sequenceDiagram
    participant Tool as generate_definitions.py
    participant Spec as Source spec/text
    participant Parser as Regex parser
    participant JSON as definitions.json

    Note over Tool,Spec: Read input spec or source lines
    Tool->>Parser: Apply relaxed regexes (STYPE, TYPED_SFIELD, LEDGER_ENTRY, TER, TRANSACTION)
    alt Match
        Parser-->>Tool: Extracted tokens/groups
        Tool->>JSON: Emit/augment types and fields (Int32, Int64, MutableFlags, DummyInt32)
        JSON-->>Tool: Write updated definitions.json
    else No match
        Parser-->>Tool: Skip or warn
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Inspect each adjusted regex (STYPE, TYPED_SFIELD, LEDGER_ENTRY, TER, TRANSACTION) for unintended over-matching.
  • Verify new TYPES and FIELDS entries in definitions.json (nth values, type names, flags).
  • Confirm removal of tedADDRESS_COLLISION and resequencing of transaction entries do not break consumers.

Possibly related PRs

Suggested reviewers

  • khancode
  • pdp2121
  • ckeshava
  • Patel-Raj11

Poem

🐰 I hopped through patterns, gentle and spry,
Spaces now welcome where tokens lie,
New integers planted, fields snug and bright,
I nudged a key away and set types right,
Hooray — definitions snug for the night! 🥕

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix: better formatting handling in definitions script' directly aligns with the main change: broadening regex patterns to permit whitespace (spaces/newlines) in the definitions generation script to handle formatting changes.
Description check ✅ Passed The description includes High Level Overview, Context of Change, Type of Change (Bug fix checked), and CHANGELOG.md status (No, checked). However, the Test Plan section is incomplete—it only states 'Works locally' without describing tests, steps to reproduce, or verification details.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-defs

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ffab72e and a353c99.

📒 Files selected for processing (1)
  • tools/generate_definitions.py (5 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: Integration test (3.9)
  • GitHub Check: Integration test (3.11)
  • GitHub Check: Integration test (3.14)
  • GitHub Check: Integration test (3.13)
  • GitHub Check: Integration test (3.12)
  • GitHub Check: Integration test (3.10)
  • GitHub Check: Integration test (3.8)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (4)
tools/generate_definitions.py (4)

174-177: LGTM! Whitespace handling properly added.

The pattern correctly allows spaces and newlines around delimiters while preserving the capture groups for type name and numeric value.


209-213: LGTM! Whitespace flexibility added appropriately.

The pattern correctly handles spaces and newlines around delimiters while appropriately excluding them from identifier capture groups (field names and type names shouldn't contain embedded whitespace).


283-287: LGTM! Flexible whitespace handling correctly implemented.

The pattern appropriately allows spaces and newlines around the assignment operator, optional comma, and before the optional comment, while preserving all capture groups.


328-331: LGTM! Correctly addresses the previous review feedback.

The pattern now requires exactly one comma (instead of ,*) while properly allowing flexible whitespace around delimiters. This addresses the previous review comment about the comma quantifier and is consistent with the PR objective to handle newlines.

Tip

📝 Customizable high-level summaries are now available in beta!

You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions:
    | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context.
    Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.


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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4a5e54c and 5028d56.

📒 Files selected for processing (1)
  • tools/generate_definitions.py (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: ckeshava
PR: XRPLF/xrpl-py#759
File: xrpl/models/transactions/credential_delete.py:57-68
Timestamp: 2024-10-30T20:34:35.451Z
Learning: Consistent implementation patterns are preferred in the `xrpl-py` codebase, especially in transaction models under `xrpl/models/transactions/`. When suggesting refactoring that affects multiple transactions, consider the impact on overall consistency and propose comprehensive changes when appropriate.

@mvadari mvadari changed the title Fix definitions script fix: better formatting handling in definitions script Oct 29, 2025
Comment on lines +3389 to +3390
"Int32": 10,
"Int64": 11,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got this comment from coderabbit when I added these two lines in my PR. Is the comment valid and should we remove these two lines?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not the only SType that isn't included in the codec, if you take a look at the full list. It doesn't matter as long as there are no fields that use the SType (which there aren't).

@mvadari mvadari enabled auto-merge (squash) November 24, 2025 20:05
@mvadari mvadari merged commit 786db5e into main Nov 24, 2025
16 of 17 checks passed
@mvadari mvadari deleted the fix-defs branch November 24, 2025 20:09
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.

5 participants