golang-migrate/migrate · error

invalid value for x-migrations-table: %w

Error message

invalid value for x-migrations-table: %w

What it means

"invalid value for x-migrations-table: %w" is raised in rqlite's parseConfigFromQuery (rqlite.go:313) when the x-migrations-table query parameter starts with the reserved prefix "sqlite_", wrapping ErrBadConfig. The driver reserves sqlite_-prefixed table names for SQLite compatibility and refuses to let the rqlite migrations table use them.

Source

Thrown at database/rqlite/rqlite.go:313

	} else {
		parsedUrl.Scheme = "https"
	}

	filteredUrl := migrate.FilterCustomQuery(parsedUrl)

	return filteredUrl, config, nil
}

func parseConfigFromQuery(queryVals nurl.Values) (*Config, error) {
	c := Config{
		ConnectInsecure: DefaultConnectInsecure,
		MigrationsTable: DefaultMigrationsTable,
	}

	migrationsTable := queryVals.Get("x-migrations-table")
	if migrationsTable != "" {
		if strings.HasPrefix(migrationsTable, "sqlite_") {
			return nil, fmt.Errorf("invalid value for x-migrations-table: %w", ErrBadConfig)
		}
		c.MigrationsTable = migrationsTable
	}

	connectInsecureStr := queryVals.Get("x-connect-insecure")
	if connectInsecureStr != "" {
		connectInsecure, err := strconv.ParseBool(connectInsecureStr)
		if err != nil {
			return nil, fmt.Errorf("invalid value for x-connect-insecure: %w", ErrBadConfig)
		}
		c.ConnectInsecure = connectInsecure
	}

	return &c, nil
}

View on GitHub (pinned to 01a9643f14)

Solutions

  1. Rename the migrations table to something without the sqlite_ prefix, e.g. x-migrations-table=schema_migrations_custom
  2. Drop the x-migrations-table param entirely to use the default schema_migrations
  3. Extract and validate the query param before building the URL

Example fix

// before
url := "rqlite://localhost:4001/db?x-migrations-table=sqlite_migrations"
// after
url := "rqlite://localhost:4001/db?x-migrations-table=migrations"
Defensive patterns

Strategy: validation

Validate before calling

q := u.Query()
table := q.Get("x-migrations-table")
if table != "" && strings.HasPrefix(table, "sqlite_") {
    return fmt.Errorf("x-migrations-table %q is reserved (sqlite_ prefix)", table)
}

Prevention

When it happens

Trigger: URLs like rqlite://host/db?x-migrations-table=sqlite_migrations or any custom table name beginning with sqlite_.

Common situations: Copying a SQLite driver URL (which allows sqlite_-prefixed tables) into the rqlite driver; a shared DSN template across SQLite and rqlite environments.

Related errors


AI-assisted analysis of golang-migrate/migrate@01a9643f14 (2026-09-02). Data as JSON: /api/errors/74056e9b21a2b54a. Report an issue: GitHub.