golang-migrate/migrate · error

x-no-tx-wrap: %s

Error message

x-no-tx-wrap: %s

What it means

Returned by Open in database/sqlite3/sqlite3.go when the x-no-tx-wrap query parameter is present in the sqlite:// URL but its value cannot be parsed as a boolean by strconv.ParseBool (e.g. x-no-tx-wrap=yes instead of true/false/1/0). It signals that the connection URL is malformed for this option; fix by supplying a valid boolean value for x-no-tx-wrap.

Source

Thrown at database/sqlite3/sqlite3.go:112

	}
	dbfile := strings.Replace(migrate.FilterCustomQuery(purl).String(), "sqlite3://", "", 1)
	db, err := sql.Open("sqlite3", dbfile)
	if err != nil {
		return nil, err
	}

	qv := purl.Query()

	migrationsTable := qv.Get("x-migrations-table")
	if len(migrationsTable) == 0 {
		migrationsTable = DefaultMigrationsTable
	}

	noTxWrap := false
	if v := qv.Get("x-no-tx-wrap"); v != "" {
		noTxWrap, err = strconv.ParseBool(v)
		if err != nil {
			return nil, fmt.Errorf("x-no-tx-wrap: %s", err)
		}
	}

	mx, err := WithInstance(db, &Config{
		DatabaseName:    purl.Path,
		MigrationsTable: migrationsTable,
		NoTxWrap:        noTxWrap,
	})
	if err != nil {
		return nil, err
	}
	return mx, nil
}

func (m *Sqlite) Close() error {
	return m.db.Close()
}

View on GitHub (pinned to 01a9643f14)

Solutions

  1. Set x-no-tx-wrap to a strconv.ParseBool-accepted value: true/false/1/0/t/f/T/F/TRUE/FALSE/True/False
  2. Remove the x-no-tx-wrap query parameter if you want the default (transactions wrapped)
  3. Log/print the final URL and validate the query string before passing it to Open

Example fix

// before
migrate.Open("sqlite3://app.db?x-no-tx-wrap=enabled")
// after
migrate.Open("sqlite3://app.db?x-no-tx-wrap=true")
Defensive patterns

Strategy: validation

Validate before calling

u, _ := url.Parse(dsn)
if v := u.Query().Get("x-no-tx-wrap"); v != "" {
    if _, err := strconv.ParseBool(v); err != nil {
        return fmt.Errorf("invalid x-no-tx-wrap %q: %w", v, err)
    }
}

Type guard

func validBoolParam(v string) bool { _, err := strconv.ParseBool(v); return v == "" || err == nil }

Try / catch

if err != nil {
    if strings.Contains(err.Error(), "x-no-tx-wrap") {
        return fmt.Errorf("bad x-no-tx-wrap value in DSN %q: %w", dsn, err)
    }
    return err
}

Prevention

When it happens

Trigger: Opening a URL like 'sqlite3://app.db?x-no-tx-wrap=yes!' or any value other than 1/t/T/true/TRUE/True/0/f/F/false/FALSE/False.

Common situations: Typos in the query value ('ture', 'on', 'yes'); generating the URL programmatically with a non-bool string; copying examples with placeholder values.

Related errors


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