From b1f147deb9970d237c7f745fdfcfe400fdf2b7d8 Mon Sep 17 00:00:00 2001 From: kolaente Date: Mon, 20 Jul 2026 13:13:46 +0200 Subject: [PATCH] fix(migration): omit duplicate values from unique-index repair error address pr-swarm finding: the error embedded raw row values; unique columns can hold secrets (token hashes, oauth codes), so report only the count --- pkg/migration/20260720120000.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/migration/20260720120000.go b/pkg/migration/20260720120000.go index 1b6c38f24..39e480317 100644 --- a/pkg/migration/20260720120000.go +++ b/pkg/migration/20260720120000.go @@ -133,15 +133,16 @@ func ensureNoDuplicates20260720120000(tx *xorm.Engine, table string, cols []stri query := "SELECT " + strings.Join(quoted, ", ") + " FROM " + tx.Quote(table) + " WHERE " + strings.Join(notNull, " AND ") + " GROUP BY " + strings.Join(quoted, ", ") + - " HAVING COUNT(*) > 1 LIMIT 1" + " HAVING COUNT(*) > 1" rows, err := tx.QueryString(query) if err != nil { return err } if len(rows) > 0 { + // Some unique-indexed columns hold secrets (token_hash, oauth codes, ...) — never log the values. return fmt.Errorf( - "cannot recreate the unique index on %s (%s) because duplicate values exist, for example %v — remove the duplicates manually, then restart Vikunja", - table, strings.Join(cols, ", "), rows[0]) + "cannot recreate the unique index on %s (%s) because %d sets of duplicate values exist — remove the duplicates manually, then restart Vikunja", + table, strings.Join(cols, ", "), len(rows)) } return nil }