Skip to content

fix: add conditional check for PermissionValue definition #3018

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 18, 2025

Conversation

khancode
Copy link
Collaborator

@khancode khancode commented Jun 18, 2025

High Level Overview of Change

Adds conditional check for PermissionValue so custom definitions (based on previous v2.x versions) don't break.

Context of Change

Bithomp reported this issue.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (non-breaking change that only restructures code)
  • Tests (You added tests for code that already exists, or your new feature included in this PR)
  • Documentation Updates
  • Release

Did you update HISTORY.md?

  • Yes
  • No, this change does not impact library users

Test Plan

Adds unit test to delete PermissionValue from defintions.json and verified it doesn't throw an error anymore.

Copy link

coderabbitai bot commented Jun 18, 2025

"""

Walkthrough

A conditional check was added to ensure the existence of the PermissionValue field before assigning its associatedType property. The changelog was updated to document this fix, which preserves compatibility with custom definitions based on previous versions. A test was added to verify encoding/decoding without the PermissionValue field.

Changes

Files/Groups Change Summary
packages/ripple-binary-codec/HISTORY.md Added an entry describing the fix for PermissionValue compatibility in the changelog.
packages/ripple-binary-codec/src/enums/xrpl-definitions-base.ts Added a conditional check for PermissionValue before assigning its associatedType property.
packages/ripple-binary-codec/test/definitions.test.ts Added a test verifying encoding and decoding works when PermissionValue field is removed.

Possibly related issues

Suggested labels

bug

Suggested reviewers

  • Patel-Raj11

Poem

A bunny hopped through fields of code,
Where PermissionValue once overflowed.
With a careful check, the bug was caught,
Compatibility—no longer fraught!
Now custom types can safely play,
Thanks to the patch merged in today.
🐇✨
"""

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

npm warn EBADENGINE Unsupported engine {
npm warn EBADENGINE package: '@es-joy/jsdoccomment@0.36.1',
npm warn EBADENGINE required: { node: '^14 || ^16 || ^17 || ^18 || ^19' },
npm warn EBADENGINE current: { node: 'v24.2.0', npm: '11.3.0' }
npm warn EBADENGINE }
npm warn EBADENGINE Unsupported engine {
npm warn EBADENGINE package: 'eslint-plugin-jsdoc@39.9.1',
npm warn EBADENGINE required: { node: '^14 || ^16 || ^17 || ^18 || ^19' },
npm warn EBADENGINE current: { node: 'v24.2.0', npm: '11.3.0' }
npm warn EBADENGINE }
npm error Exit handler never called!
npm error This is an error with npm itself. Please report this error at:
npm error https://github.com/npm/cli/issues
npm error A complete log of this run can be found in: /.npm/_logs/2025-06-18T19_26_02_995Z-debug-0.log


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2f53699 and cd8f47f.

📒 Files selected for processing (3)
  • packages/ripple-binary-codec/HISTORY.md (1 hunks)
  • packages/ripple-binary-codec/src/enums/xrpl-definitions-base.ts (1 hunks)
  • packages/ripple-binary-codec/test/definitions.test.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/ripple-binary-codec/HISTORY.md
  • packages/ripple-binary-codec/src/enums/xrpl-definitions-base.ts
  • packages/ripple-binary-codec/test/definitions.test.ts
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: generate-documentation (22.x)
  • GitHub Check: browser (22.x)
  • GitHub Check: unit (20.x)
  • GitHub Check: unit (22.x)
  • GitHub Check: build-and-lint (22.x)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: integration (20.x)
  • GitHub Check: integration (22.x)
✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Patel-Raj11
Copy link
Collaborator

Can we add a test here that removes PermissionValue and makes sure that encode and decode of a transaction works fine?
https://github.com/XRPLF/xrpl.js/blob/ea649338e7962300a0d60f1e358f5f4e36e51d85/packages/ripple-binary-codec/test/definitions.test.ts

Copy link
Collaborator

@Patel-Raj11 Patel-Raj11 left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link

@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: 0

🧹 Nitpick comments (1)
packages/ripple-binary-codec/test/definitions.test.ts (1)

168-172: Consider adding a guard for edge case scenarios.

While the current implementation is correct, consider adding a guard to handle the edge case where PermissionValue might not exist in the original definitions.

  // Remove PermissionValue from definitions
  if (definitions.FIELDS) {
+   const originalPermissionValue = definitions.FIELDS.find(
+     (fieldTuple: [string, object]) => fieldTuple[0] === 'PermissionValue'
+   )
+   
    definitions.FIELDS = definitions.FIELDS.filter(
      (fieldTuple: [string, object]) => fieldTuple[0] !== 'PermissionValue',
    )
+   
+   // Only verify removal if PermissionValue was originally present
+   if (originalPermissionValue) {
+     const expectedFieldsLength = originalFieldsLength - 1
+     expect(definitions.FIELDS.length).toBe(expectedFieldsLength)
+   }
  }
-
- // Verify it was deleted
- const expectedFieldsLength = originalFieldsLength - 1
- expect(definitions.FIELDS.length).toBe(expectedFieldsLength)
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3cbb2d7 and 2f53699.

📒 Files selected for processing (1)
  • packages/ripple-binary-codec/test/definitions.test.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: integration (22.x)
  • GitHub Check: integration (20.x)
  • GitHub Check: browser (22.x)
  • GitHub Check: unit (22.x)
  • GitHub Check: unit (20.x)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: build-and-lint (22.x)
🔇 Additional comments (1)
packages/ripple-binary-codec/test/definitions.test.ts (1)

161-188: LGTM! Well-implemented test case addressing the PR requirements.

This test effectively validates the conditional check fix for PermissionValue definition that was mentioned in the PR objectives. The implementation follows the established patterns in the test file and properly addresses the concern raised by Patel-Raj11 about adding test coverage.

The test logic is sound:

  • Creates a proper deep copy of definitions
  • Correctly removes the PermissionValue field using array filtering
  • Verifies the removal was successful
  • Tests that encoding/decoding still works without errors

@khancode khancode force-pushed the permission-value-check branch from 2f53699 to cd8f47f Compare June 18, 2025 19:25
@khancode khancode merged commit 53c00e7 into main Jun 18, 2025
14 checks passed
@khancode khancode deleted the permission-value-check branch June 18, 2025 19:28
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.

breaking change in the latest implementation of ripple-binary-codec 2.4.0
3 participants