Skip to content

Conversation

@ViktorT-11
Copy link
Contributor

If there are no RPCParamsJson set for an action, the value is represented differently in KVDB vs SQL.
In the SQL DB, empty RPCParamsJson are represented as nil, while they are represented as an empty array in the KVDB version. This PR addresses that issue, by overriding the RPCParamsJson in that scenario, so that they are set to the same representation when a KVDB and an SQL action is compared.

@gemini-code-assist
Copy link

Summary of Changes

Hello @ViktorT-11, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical data representation discrepancy encountered during the migration of firewall actions from KVDB to SQL. Specifically, it rectifies the inconsistent handling of empty RPCParamsJson fields, which were stored as an empty array in KVDB but as nil in SQL. By introducing a new override mechanism and corresponding test cases, the PR ensures that these fields are uniformly represented across both database systems, thereby maintaining data integrity and preventing validation failures during the migration process.

Highlights

  • Data Consistency Fix: Resolved an inconsistency in how empty RPCParamsJson values are represented between KVDB (as an empty array) and SQL (as nil), ensuring uniform data representation during migration.
  • New Override Function: Introduced overrideRPCParamsJson in firewalldb/sql_migration.go to explicitly set sqlAction.RPCParamsJson to an empty byte slice ([]byte{}) when the KVDB action's RPCParamsJson is empty and the SQL action's is nil, standardizing the representation.
  • Enhanced Test Coverage: Added a new test case, action with empty RPCParamsJson, to TestFirewallDBMigration to validate the correct handling of actions where RPCParamsJson is empty, along with a new helper function actionEmptyRPCParamsJson.
  • Test Helper Adjustments: Modified the addAction helper to ensure that when actionReq.RPCParamsJson is empty, the action.RPCParamsJson is correctly set to nil for SQL representation in tests. Also, randomJSON was updated to handle zero-length JSON generation.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly addresses the discrepancy in representing empty RPCParamsJson between KVDB and SQL databases during migration by overriding the value for comparison. The main logic in sql_migration.go is sound. However, I've found a couple of issues in the test files that need to be addressed. One is an incorrect modification in a test helper function that affects the validation logic, and another is a helper function that generates invalid JSON. My review provides specific suggestions to resolve these points.

@lightninglabs-deploy
Copy link

@ViktorT-11, remember to re-request review from reviewers when ready

If there are no RPCParamsJson set for an action, the value is
represented differently in KVDB vs SQL.
In the SQL DB, empty RPCParamsJson are represented as nil, while they
are represented as an empty array in the KVDB version. Therefore, we
need to override the RPCParamsJson in that scenario, so that they are
set to the same representation when a KVDB and an SQL action is
compared.
@ViktorT-11 ViktorT-11 force-pushed the 2025-10-action-mig-handle-empty-RPCParamsJson branch from 1d85de8 to 1d184b8 Compare November 5, 2025 15:47
@ViktorT-11 ViktorT-11 added the no-changelog This PR is does not require a release notes entry label Nov 5, 2025
Copy link
Member

@ellemouton ellemouton left a comment

Choose a reason for hiding this comment

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

lgtm!

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

Labels

no-changelog This PR is does not require a release notes entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants