Skip to content

kvdb/sqlbase: fix non-constant format strings#10793

Merged
Roasbeef merged 1 commit into
lightningnetwork:masterfrom
aakselrod:fix-sqlbase-nonconst-fmt-strings
May 7, 2026
Merged

kvdb/sqlbase: fix non-constant format strings#10793
Roasbeef merged 1 commit into
lightningnetwork:masterfrom
aakselrod:fix-sqlbase-nonconst-fmt-strings

Conversation

@aakselrod
Copy link
Copy Markdown
Contributor

@aakselrod aakselrod commented May 6, 2026

Change Description

When updating the Go version in kvdb to >= 1.24, schema.go no longer compiles due to non-constant format strings. This is invisible until:

  • a new version of kvdb is tagged and imported in consumers
  • kvdb is redirected to the local copy

This commit fixes the bug. I'm happy to add a release note to either the 0.21 or 0.22 version depending on when people want to merge this.

Steps to Test

In the top-level go.mod file, add a KVDB redirect:

replace github.com/lightningnetwork/lnd/kvdb => ./kvdb

Run make unit dbbackend=postgres before and after this change. Before the change, you should get two errors similar to this:

# github.com/lightningnetwork/lnd/kvdb/sqlbase                                                                                          
kvdb/sqlbase/schema.go:25:5: non-constant format string in call to fmt.Sprintf                                                          
kvdb/sqlbase/schema.go:49:26: non-constant format string in call to fmt.Sprintf                                                         
FAIL    github.com/lightningnetwork/lnd/kvdb/sqlbase [build failed]                                                                     
FAIL                                                                                                                                    

After the change, the bug should be fixed.

Pull Request Checklist

Testing

  • Your PR passes all CI checks.
  • Tests covering the positive and negative (error paths) are included.
  • Bug fixes contain tests triggering the bug to prevent regressions.

Code Style and Documentation

📝 Please see our Contribution Guidelines for further guidance.

When updating the Go version in kvdb to >= 1.24, schema.go no
longer compiles due to non-constant format strings. This is
invisible until:
- a new version of kvdb is tagged and imported in consumers
- kvdb is redirected to the local copy

This commit fixes the bug.
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, 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 compilation issue introduced by Go 1.24, which enforces stricter checks on format strings used in fmt.Sprintf. By refactoring the SQL schema generation logic to use explicit format specifiers, the changes ensure that the package remains compatible with the latest Go toolchain while maintaining existing functionality.

Highlights

  • Build Compatibility: Updated schema generation logic to comply with Go 1.24+ requirements regarding constant format strings in fmt.Sprintf.
  • Code Refactoring: Refactored SQL string construction in kvdb/sqlbase/schema.go to use explicit format specifiers, preventing build failures in newer Go versions.
New Features

🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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 the 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 counterproductive. 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.

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.

@github-actions github-actions Bot added the severity-medium Focused review required label May 6, 2026
Copy link
Copy Markdown

@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 modifies the SQL schema and table creation commands in kvdb/sqlbase/schema.go by wrapping string concatenations within fmt.Sprintf calls using a %s format specifier. The review feedback correctly identifies that these fmt.Sprintf calls are redundant and less idiomatic than direct string assignment or concatenation. It is recommended to simplify the code by removing the unnecessary function calls while maintaining consistent spacing around operators.

Comment thread kvdb/sqlbase/schema.go
Comment thread kvdb/sqlbase/schema.go
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 6, 2026

🟡 PR Severity: MEDIUM

Classified from changed files | 1 file | 22 lines changed

🟡 Medium (1 file)
  • kvdb/sqlbase/schema.go - kvdb/* package: key-value database abstraction layer

Analysis

This PR modifies a single file in the kvdb/sqlbase/ package, which falls under the kvdb/* classification (MEDIUM severity). The change is small (11 additions, 11 deletions — a net-zero diff of 22 lines) and touches only the SQL schema definitions used by the KV database abstraction layer.

No severity bump rules apply:

  • File count: 1 (well below the 20-file threshold)
  • Lines changed: 22 (well below the 500-line threshold)
  • No multiple distinct critical packages touched
  • No database migrations detected (not a migration file)

A focused review by a knowledgeable engineer familiar with the kvdb/SQL backend is appropriate.


To override, add a severity-override-{critical,high,medium,low} label.
<!-- pr-severity-bot -->

Copy link
Copy Markdown
Collaborator

@ziggie1984 ziggie1984 left a comment

Choose a reason for hiding this comment

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

LGTM, I don't think release notes are necessary here

@saubyk saubyk requested a review from bhandras May 7, 2026 14:27
@saubyk saubyk added this to lnd v0.22 May 7, 2026
@github-project-automation github-project-automation Bot moved this to Backlog in lnd v0.22 May 7, 2026
@saubyk saubyk moved this from Backlog to In review in lnd v0.22 May 7, 2026
@Roasbeef Roasbeef merged commit 50eb0d1 into lightningnetwork:master May 7, 2026
50 of 54 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in lnd v0.22 May 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog severity-medium Focused review required

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants