What changed, and why it matters
This commit fixes a mistake in an error message: when a SQLite database migration setup failed, the error incorrectly blamed Postgres. The actual database behavior was unaffected; only the wording of a rare error path changed. A new test was added to confirm the error now correctly says 'sqlite'.
No security action required; this is a non-security bug fix improving error-message accuracy.
Security signals we found
No strong security signals were identified.
Evidence from the diff
In sqldb/v2/sqlite.go, executeMigrations now wraps MakeProgrammaticMigrations failures with errSqliteMigration(err) instead of errPostgresMigration(err). The change is purely cosmetic/correctness for error attribution. A new internal test forces the failing constructor path and asserts the returned error contains ‘sqlite’ and does not contain ‘postgres’.
Changed components
sqldb/v2/sqlite.gosqldb/v2/sqlite_internal_test.goInspect captured patch +40 / −1
diff --git a/sqldb/v2/sqlite.go b/sqldb/v2/sqlite.go
index f53685f..8967ff5 100644
--- a/sqldb/v2/sqlite.go
+++ b/sqldb/v2/sqlite.go
@@ -277,7 +277,7 @@ func (s *SqliteStore) executeMigrations(target MigrationTarget,
if set.MakeProgrammaticMigrations != nil {
postMigSteps, err := set.MakeProgrammaticMigrations(s.BaseDB)
if err != nil {
- return errPostgresMigration(err)
+ return errSqliteMigration(err)
}
opts.programmaticMigrs = postMigSteps
}
diff --git a/sqldb/v2/sqlite_internal_test.go b/sqldb/v2/sqlite_internal_test.go
new file mode 100644
index 0000000..43059fb
--- /dev/null
+++ b/sqldb/v2/sqlite_internal_test.go
@@ -0,0 +1,39 @@
+//go:build !js && !(windows && (arm || 386)) && !(linux && (ppc64 || mips || mipsle || mips64))
+
+package sqldb
+
+import (
+ "errors"
+ "path/filepath"
+ "testing"
+
+ "github.com/golang-migrate/migrate/v4"
+ "github.com/stretchr/testify/require"
+)
+
+// TestSqliteProgrammaticMigrationError verifies that SQLite migration setup
+// failures are attributed to the SQLite backend.
+func TestSqliteProgrammaticMigrationError(t *testing.T) {
+ t.Parallel()
+
+ store, err := NewSqliteStore(
+ &SqliteConfig{}, filepath.Join(t.TempDir(), "test.db"),
+ )
+ require.NoError(t, err)
+ t.Cleanup(func() {
+ require.NoError(t, store.Close())
+ })
+
+ boom := errors.New("boom")
+ err = store.ExecuteMigrations(MigrationSet{
+ TrackingTableName: "migration_tracker",
+ LatestMigrationVersion: 1,
+ MakeProgrammaticMigrations: func(*BaseDB) (
+ map[uint]migrate.ProgrammaticMigrEntry, error) {
+
+ return nil, boom
+ },
+ })
+ require.ErrorContains(t, err, "sqlite")
+ require.NotContains(t, err.Error(), "postgres")
+}
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.