Skip to content

Conversation

@hi-rai
Copy link
Contributor

@hi-rai hi-rai commented Dec 11, 2025

Fixed advisory lock. Also upgraded Go version and package dependencies.

Also upgraded Go version and package dependencies.
@hi-rai hi-rai requested a review from satvik007 December 11, 2025 06:09
@hi-rai hi-rai self-assigned this Dec 11, 2025
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @hi-rai, 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 primarily focuses on maintenance, security, and robustness improvements. It updates the Go language version and several critical package dependencies to ensure the project benefits from the latest features and security patches. A significant change involves fixing a potential SQL injection vulnerability in a database query function. Additionally, it refines error handling logic in two functions and ensures that advisory locks are correctly applied within the scope of a database transaction, enhancing data integrity.

Highlights

  • Go Version Upgrade: The Go language version has been updated from 1.24 to 1.25.
  • Dependency Updates: Several key dependencies, including github.com/stretchr/testify, github.com/uptrace/bun, github.com/vmihailenco/msgpack/v5, and golang.org/x/sys, have been upgraded to their latest versions.
  • SQL Injection Fix: A potential SQL injection vulnerability in the ExistsBySQL function has been addressed by properly quoting the table name using bun.Ident.
  • Error Handling Refinement: The UpdateSQLByID and UpsertIgnore functions now correctly return nil upon successful execution after handling potential errors.
  • Transactional Advisory Lock: The advisoryLock call within RunInLockedTx now correctly uses the transaction context (tx) instead of the main database instance (m), ensuring proper transactional integrity for locks.
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
Contributor

@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 addresses an issue with advisory locks, upgrades the Go version, and updates package dependencies. The primary fix in RunInLockedTx correctly ensures that the advisory lock is acquired within the transaction's context, which is a crucial correction for data consistency.

My review has identified a critical security concern in hyperbun.go. While an SQL injection vulnerability was partially addressed in ExistsBySQL by parameterizing the table name, the query string is still concatenated directly, leaving a significant SQL injection risk. The other changes are minor improvements to code clarity.

Comment on lines 270 to 272
if err := m.NewRaw("SELECT EXISTS(SELECT 1 from ? WHERE "+query+")",
append([]interface{}{bun.Ident(table)}, args...)...).
Scan(m.Context(), &exists); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

security-critical critical

This change correctly parameterizes the table name to prevent SQL injection, which is a great improvement. However, a similar vulnerability still exists with the query parameter, which is directly concatenated into the SQL string. This can lead to SQL injection if the query string is constructed with untrusted input.

For example, a call like this would be vulnerable:

ExistsBySQL(db, "users", "username = '" + userInput + "'")

While the function seems to intend for args to be used for parameterization, relying on developers to always do this correctly for the query string is risky. To fully mitigate this, the query string should also be built in a safe way, not through concatenation. A safer approach would be to use Bun's query builder instead of raw SQL strings.

hi-rai and others added 4 commits December 11, 2025 11:48
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@satvik007 satvik007 merged commit 3c9b934 into main Dec 11, 2025
1 check passed
@satvik007 satvik007 deleted the fix-advisory-lock branch December 11, 2025 09:36
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.

3 participants