invoices: add TODO to change the return type of the query
What changed, and why it matters
This commit only adds code comments (TODOs) suggesting a future cleanup: a database query currently returns a list of invoices, but because of the table's primary key it can actually return at most one. No code behavior is changed, so there is no security issue in this commit itself.
No security action needed for this commit. The TODO can be addressed later as a refactoring item if desired.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff adds identical TODO comments in three generated SQLc-related files noting that GetInvoiceBySetID returns []Invoice but, because set_id is the primary key of amp_sub_invoices, the query can return at most one row. The function signature, query text, and logic are unchanged. This is a maintainability note, not a functional or security fix.
Changed components
sqldb/sqlc/invoices.sql.gosqldb/sqlc/querier.gosqldb/sqlc/queries/invoices.sqlInspect captured patch +6 / −0
diff --git a/sqldb/sqlc/invoices.sql.go b/sqldb/sqlc/invoices.sql.go
index 99e9739..cbf2cdb 100644
--- a/sqldb/sqlc/invoices.sql.go
+++ b/sqldb/sqlc/invoices.sql.go
@@ -547,6 +547,8 @@ INNER JOIN amp_sub_invoices a
ON i.id = a.invoice_id AND a.set_id = $1
`
+// TODO(ziggie): This query can only return one invoice if the set_id is
+// the primary key of amp_sub_invoices table.
func (q *Queries) GetInvoiceBySetID(ctx context.Context, setID []byte) ([]Invoice, error) {
rows, err := q.db.QueryContext(ctx, getInvoiceBySetID, setID)
if err != nil {
diff --git a/sqldb/sqlc/querier.go b/sqldb/sqlc/querier.go
index 5b9c7d5..9182794 100644
--- a/sqldb/sqlc/querier.go
+++ b/sqldb/sqlc/querier.go
@@ -113,6 +113,8 @@ type Querier interface {
GetInvoice(ctx context.Context, arg GetInvoiceParams) ([]Invoice, error)
GetInvoiceByAddr(ctx context.Context, paymentAddr []byte) (Invoice, error)
GetInvoiceByHash(ctx context.Context, hash []byte) (Invoice, error)
+ // TODO(ziggie): This query can only return one invoice if the set_id is
+ // the primary key of amp_sub_invoices table.
GetInvoiceBySetID(ctx context.Context, setID []byte) ([]Invoice, error)
GetInvoiceFeatures(ctx context.Context, invoiceID int64) ([]InvoiceFeature, error)
GetInvoiceHTLCCustomRecords(ctx context.Context, invoiceID int64) ([]GetInvoiceHTLCCustomRecordsRow, error)
diff --git a/sqldb/sqlc/queries/invoices.sql b/sqldb/sqlc/queries/invoices.sql
index 22e5cd0..dab1ff0 100644
--- a/sqldb/sqlc/queries/invoices.sql
+++ b/sqldb/sqlc/queries/invoices.sql
@@ -65,6 +65,8 @@ FROM invoices i
WHERE i.payment_addr = $1;
-- name: GetInvoiceBySetID :many
+-- TODO(ziggie): This query can only return one invoice if the set_id is
+-- the primary key of amp_sub_invoices table.
SELECT i.*
FROM invoices i
INNER JOIN amp_sub_invoices a
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.