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

Aperta
#2,146 0 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@Wikid82 ci sta già lavorando.

Dal 3/12/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

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.

Lingua principale
Go
Stelle
17
Fork
2
Merge medio
1h 42m
PR unite (30g)
173

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Wikid82/Charon

Tutte le issue di Wikid82/Charon

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.