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

Đang mở
#2,146 0 bình luận 0 reaction 1 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@Wikid82 đang làm issue này rồi.

Từ ngày 3/12/2026.

Đánh giá

Issue này chưa được đánh giá.

Mô tả

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.

Ngôn ngữ chính
Go
Star
17
Fork
2
Merge trung bình
1 giờ 42 phút
Pull request đã merge (30 ngày)
173

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Wikid82/Charon

Tất cả issue của Wikid82/Charon

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.