golang-migrate/migrate · warning

no match

Error message

no match

What it means

ErrParse ('no match') is returned by source.Parse when a filename does not match the default migration filename regex, and propagated by drivers (e.g. the gitlab nodeToMigration at gitlab.go:164) for names that cannot be interpreted as versioned migration files. Normally parse failures are filtered silently by drivers, so seeing this error means a code path surfaced a non-conforming filename directly.

Source

Thrown at source/parse.go:10

package source

import (
	"fmt"
	"regexp"
	"strconv"
)

var (
	ErrParse = fmt.Errorf("no match")
)

var (
	DefaultParse = Parse
	DefaultRegex = Regex
)

// Regex matches the following pattern:
//
//	123_name.up.ext
//	123_name.down.ext
var Regex = regexp.MustCompile(`^([0-9]+)_(.*)\.(` + string(Down) + `|` + string(Up) + `)\.(.*)$`)

// Parse returns Migration for matching Regex pattern.
func Parse(raw string) (*Migration, error) {
	m := Regex.FindStringSubmatch(raw)
	if len(m) == 5 {
		versionUint64, err := strconv.ParseUint(m[1], 10, 64)

View on GitHub (pinned to 01a9643f14)

Solutions

  1. Rename the file to the expected format: version_description.direction.ext, e.g. 0001_create_users.up.sql
  2. Verify the leading version number is present — the default regex requires a numeric prefix
  3. If using a nonstandard naming scheme, set a custom regex/parser (source.SetDefault or a driver-specific option if available) that accepts your filenames
  4. Ensure callers skip or log unparseable files rather than failing the whole migration set, matching driver behavior like 'continue' on parse error

Example fix

// before
source.Parse("create_users.up.sql") // ErrParse: no match
// after
source.Parse("0001_create_users.up.sql") // ok
Defensive patterns

Strategy: validation

Validate before calling

var migrationNameRe = regexp.MustCompile(`^([0-9]+)_[^.]+\.(up|down)\.(sql|...)`)
func isMigrationName(name string) bool {
    return migrationNameRe.MatchString(name)
}

Try / catch

m, err := source.Parse(name)
if errors.Is(err, source.ErrParse) {
    // not a migration file; skip or log instead of failing
    log.Printf("skipping non-migration file %q", name)
    return nil
}

Prevention

When it happens

Trigger: Calling source.Parse with a filename lacking a numeric version prefix (e.g. 'init.sql' instead of '0001_init.sql'); gitlab's nodeToMigration returning it for API entries whose names don't match the migration pattern.

Common situations: Migration files missing the NNN_description.(up|down).sql convention; drivers configured to surface files the default regex rejects; custom parsers replacing DefaultParse with a stricter regex; stray files (README, .keep) in migration directories when a caller doesn't skip unparseable names.

Related errors


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