Chained GORM conditions on a pinned connection can leak into the next query

オープン
#2,146 コメント 0 件 リアクション 0 件 担当者 1 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@Wikid82 がすでに取り組んでいます。

2026年12月3日 から。

評価

この issue はまだ評価されていません。

説明

backend bug low

What: a function that runs more than one query on a pinned *gorm.DB connection (for example the single-connection migration path, backend/internal/api/routes/migrate.go) can have conditions from one query carry into the next, because GORM builds on the receiver's existing statement unless a fresh session is started. This was hit while writing services.KeepManagementCountryListsExcludingLocal (added in PR closing #1895/#1980): a follow-up query on the same pinned connection picked up a leftover key = ? condition from an earlier, unrelated query and failed with "no such column: uuid". The fix there was to start each query from conn.Session(&gorm.Session{NewDB: true}).

Where: any function that chains more than one top-level query call against a single pinned connection, including other migration-path or management-access helpers in backend/internal/services/management_access.go (for example ManagementListUUIDs, if called more than once from the same pinned connection without an intervening fresh session).

Suggested approach: audit callers that reuse a pinned connection across more than one query and have them call .Session(&gorm.Session{NewDB: true}) (or an equivalent fresh-statement pattern) before each independent query, rather than relying on the caller never chaining unrelated conditions.

Severity: low (correctness/reliability only, no data exposure — surfaces as a query failure, not a wrong result returned to a caller).

Found during B8-05 implementation.

主要言語
Go
スター
17
フォーク
2
平均マージ
1時間 42分
マージ済み PR(30日)
173

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Wikid82/Charon のほかの issue

Wikid82/Charon の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。