{"record":{"id":"86f5b7e4759bacd1","repo":"golang-migrate/migrate","slug":"no-match","errorCode":null,"errorMessage":"no match","messagePattern":"no match","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"source/parse.go","lineNumber":10,"sourceCode":"package source\n\nimport (\n\t\"fmt\"\n\t\"regexp\"\n\t\"strconv\"\n)\n\nvar (\n\tErrParse = fmt.Errorf(\"no match\")\n)\n\nvar (\n\tDefaultParse = Parse\n\tDefaultRegex = Regex\n)\n\n// Regex matches the following pattern:\n//\n//\t123_name.up.ext\n//\t123_name.down.ext\nvar Regex = regexp.MustCompile(`^([0-9]+)_(.*)\\.(` + string(Down) + `|` + string(Up) + `)\\.(.*)$`)\n\n// Parse returns Migration for matching Regex pattern.\nfunc Parse(raw string) (*Migration, error) {\n\tm := Regex.FindStringSubmatch(raw)\n\tif len(m) == 5 {\n\t\tversionUint64, err := strconv.ParseUint(m[1], 10, 64)","sourceCodeStart":1,"sourceCodeEnd":28,"githubUrl":"https://github.com/golang-migrate/migrate/blob/01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a/source/parse.go#L1-L28","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Rename the file to the expected format: version_description.direction.ext, e.g. 0001_create_users.up.sql","Verify the leading version number is present — the default regex requires a numeric prefix","If using a nonstandard naming scheme, set a custom regex/parser (source.SetDefault or a driver-specific option if available) that accepts your filenames","Ensure callers skip or log unparseable files rather than failing the whole migration set, matching driver behavior like 'continue' on parse error"],"exampleFix":"// before\nsource.Parse(\"create_users.up.sql\") // ErrParse: no match\n// after\nsource.Parse(\"0001_create_users.up.sql\") // ok","handlingStrategy":"validation","validationCode":"var migrationNameRe = regexp.MustCompile(`^([0-9]+)_[^.]+\\.(up|down)\\.(sql|...)`)\nfunc isMigrationName(name string) bool {\n    return migrationNameRe.MatchString(name)\n}","typeGuard":null,"tryCatchPattern":"m, err := source.Parse(name)\nif errors.Is(err, source.ErrParse) {\n    // not a migration file; skip or log instead of failing\n    log.Printf(\"skipping non-migration file %q\", name)\n    return nil\n}","preventionTips":["Follow the version_description.direction.ext naming convention strictly","Add a CI lint that parses every file in migration directories with source.DefaultParse","Keep READMEs and dotfiles out of migration directories","If customizing, replace DefaultRegex/DefaultParse once and test it against all real filenames"],"tags":["parsing","migration","naming","regex"],"backgroundTag":"migration-filename-parse-failed","analyzedSha":"01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a","analyzedAt":"2026-09-02T19:38:29.671Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}