golang-migrate/migrate · error

bad parameter

Error message

bad parameter

What it means

ErrBadConfig (message "bad parameter") is the rqlite driver's generic configuration error. parseUrl and parseConfigFromQuery wrap it with %w for specific failures: a non-rqlite URL scheme, an x-migrations-table query param starting with sqlite_, or a non-boolean x-connect-insecure value. Because it is always wrapped, use errors.Is(err, rqlite.ErrBadConfig) to detect it and read the wrapper text for the exact cause.

Solutions

  1. Fix the specific part named in the wrapped error text: scheme, x-migrations-table, or x-connect-insecure
  2. Use scheme rqlite (or rqlites for TLS) in the URL — Open adapts it to http/https internally
  3. Choose a migrations table name that does not start with sqlite_
  4. Use a value strconv.ParseBool accepts for x-connect-insecure: 1/t/T/TRUE/true/True/0/f/F/FALSE/false/False
  5. In Go code, branch on errors.Is(err, rqlite.ErrBadConfig) to report a config problem rather than a connection problem

Example fix

// before
url := "https://localhost:4001/db?x-connect-insecure=yes"
// after
url := "rqlite://localhost:4001/db?x-connect-insecure=true"
Defensive patterns

Strategy: validation

Validate before calling

u, err := url.Parse(dsn)
if err != nil { return err }
if u.Scheme != "rqlite" { return fmt.Errorf("scheme must be rqlite, got %q", u.Scheme) }
q := u.Query()
if t := q.Get("x-migrations-table"); strings.HasPrefix(t, "sqlite_") { return fmt.Errorf("x-migrations-table cannot start with sqlite_") }
if v := q.Get("x-connect-insecure"); v != "" {
    if _, err := strconv.ParseBool(v); err != nil { return fmt.Errorf("x-connect-insecure must be a Go bool") }
}

Try / catch

if err != nil {
    if errors.Is(err, rqlite.ErrBadConfig) {
        log.Fatalf("rqlite driver misconfiguration: %v", err)
    }
    return err
}

Prevention

When it happens

Trigger: Opening rqlite://... with the wrong scheme; passing x-migrations-table=sqlite_foo in the URL query; passing x-connect-insecure=yes/no-on-off-nonbool (anything strconv.ParseBool rejects, e.g. "yes" or "2").

Common situations: Reusing a connection URL from an http/https-based client and forgetting the scheme must be exactly rqlite; copying SQLite migration table naming conventions (sqlite_*) into rqlite; hand-writing the DSN with an unchecked boolean param.

Related errors


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

Appendix: source

Thrown at database/rqlite/rqlite.go:33

)

func init() {
	database.Register("rqlite", &Rqlite{})
}

const (
	// DefaultMigrationsTable defines the default rqlite migrations table
	DefaultMigrationsTable = "schema_migrations"

	// DefaultConnectInsecure defines the default setting for connect insecure
	DefaultConnectInsecure = false
)

// ErrNilConfig is returned if no configuration was passed to WithInstance
var ErrNilConfig = fmt.Errorf("no config")

// ErrBadConfig is returned if configuration was invalid
var ErrBadConfig = fmt.Errorf("bad parameter")

// Config defines the driver configuration
type Config struct {
	// ConnectInsecure sets whether the connection uses TLS. Ineffectual when using WithInstance
	ConnectInsecure bool
	// MigrationsTable configures the migrations table name
	MigrationsTable string
}

type Rqlite struct {
	db       *gorqlite.Connection
	isLocked atomic.Bool

	config *Config
}

// WithInstance creates a rqlite database driver with an existing gorqlite database connection
// and a Config struct

View on GitHub (pinned to 01a9643f14)