golang-migrate/migrate · error

no config

Error message

no config

What it means

ErrNilConfig in database/firebird is the package-level sentinel returned when a Firebird driver constructor (WithInstance, WithConnection) or extractCustomQueryParams receives a nil *Config. It means the caller invoked the driver without supplying migration configuration (e.g. DatabaseName/MigrationsTable), so the driver cannot proceed. It is a static guard error, never network-related.

Source

Thrown at database/firebird/firebird.go:28

	"io"
	nurl "net/url"
	"sync/atomic"

	"github.com/golang-migrate/migrate/v4"
	"github.com/golang-migrate/migrate/v4/database"
	_ "github.com/nakagami/firebirdsql"
)

func init() {
	db := Firebird{}
	database.Register("firebird", &db)
	database.Register("firebirdsql", &db)
}

var DefaultMigrationsTable = "schema_migrations"

var (
	ErrNilConfig = fmt.Errorf("no config")
)

type Config struct {
	DatabaseName    string
	MigrationsTable string
}

type Firebird struct {
	// Locking and unlocking need to use the same connection
	conn     *sql.Conn
	db       *sql.DB
	isLocked atomic.Bool

	// Open and WithInstance need to guarantee that config is never nil
	config *Config
}

func WithInstance(instance *sql.DB, config *Config) (database.Driver, error) {

View on GitHub (pinned to 01a9643f14)

Solutions

  1. Pass a non-nil *firebird.Config to WithInstance/WithConnection
  2. Build config via firebird.WithConfig(dsn) instead of hand-constructing a zero pointer
  3. Check for nil config in your own wrapper before calling the driver

Example fix

// before
var cfg *firebird.Config
d, err := firebird.WithInstance(conn, cfg)
// after
cfg, err := firebird.WithConfig("user:pass@host/db")
if err != nil { return err }
d, err := firebird.WithInstance(conn, cfg)
Defensive patterns

Strategy: validation

Validate before calling

if cfg == nil {
    return fmt.Errorf("firebird migration requires a config: build one via firebird.WithConfig(dsn)")
}

Type guard

func hasFirebirdConfig(cfg *firebird.Config) bool { return cfg != nil }

Try / catch

if err != nil {
    if errors.Is(err, firebird.ErrNilConfig) {
        // fix bootstrap config wiring
    }
    return err
}

Prevention

When it happens

Trigger: Calling firebird.WithInstance(conn, nil) or firebird.WithConnection(db, nil); calling WithConfig/WithInstance via the migrate framework with an empty config pointer; extractCustomQueryParams invoked with nil config.

Common situations: Constructing a migrate instance with a typed nil *firebird.Config, forgetting to call firebird.WithConfig/WithInstance before use, or passing config through a helper that silently drops nil pointers.

Related errors


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