{"record":{"id":"b75b83d0a718252c","repo":"ory/hydra","slug":"unknown-migration-direction-q-for-q","errorCode":null,"errorMessage":"unknown migration direction %q for %q","messagePattern":"unknown migration direction %q for %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"oryx/popx/migration_box.go","lineNumber":326,"sourceCode":"\t\t\tPath:       p,\n\t\t\tVersion:    details.Version,\n\t\t\tName:       details.Name,\n\t\t\tDBType:     details.DBType,\n\t\t\tDirection:  details.Direction,\n\t\t\tType:       details.Type,\n\t\t\tContent:    string(content),\n\t\t\tAutocommit: details.Autocommit,\n\t\t}\n\n\t\tmf.Runner = runner(content)\n\n\t\tswitch details.Direction {\n\t\tcase \"up\":\n\t\t\tmb.migrationsUp = append(mb.migrationsUp, mf)\n\t\tcase \"down\":\n\t\t\tmb.migrationsDown = append(mb.migrationsDown, mf)\n\t\tdefault:\n\t\t\treturn errors.Errorf(\"unknown migration direction %q for %q\", details.Direction, info.Name())\n\t\t}\n\t\treturn nil\n\t})\n\n\t// Sort descending.\n\tsort.Sort(mb.migrationsDown)\n\tslices.Reverse(mb.migrationsDown)\n\n\t// Sort ascending.\n\tsort.Sort(mb.migrationsUp)\n\n\treturn errors.WithStack(err)\n}\n\n// hasDownMigrationWithVersion checks if there is a migration with the given\n// version.\nfunc (mb *MigrationBox) hasDownMigrationWithVersion(version string) bool {\n\tfor _, down := range mb.migrationsDown {","sourceCodeStart":308,"sourceCodeEnd":344,"githubUrl":"https://github.com/ory/hydra/blob/4174065ffb052799890f7480f5360a877a67ffc1/oryx/popx/migration_box.go#L308-L344","documentation":"Migration filenames encode the direction as .up. or .down.; findMigrations appends each parsed migration to migrationsUp or migrationsDown based on details.Direction. If a parsed match carries any other direction, this error (oryx/popx/migration_box.go:326) reports the unknown direction together with the filename. Given the regex only captures up|down, this is a defensive check against corrupted parse results.","triggerScenarios":"A migration's parsed Direction is neither \"up\" nor \"down\" while loading migrations from a filesystem/directory.","commonSituations":"Custom/modified file-pattern parsing producing unexpected direction values; a monkey-patched or divergent regex in a fork; corrupted embedded filesystem entries.","solutions":["Check the migration filename contains a valid .up. or .down. direction segment and fix it","If you forked or patched the parsing logic, ensure the direction capture is limited to (up|down)","Rebuild the binary/embed FS so the migrations directory contents match the expected format"],"exampleFix":"// before\n20240101000000_add_users_table.all.sql (no direction)\n// after\n20240101000000_add_users_table.up.sql","handlingStrategy":"validation","validationCode":"re := regexp.MustCompile(`^(\\d+)_([^.]+)(\\.[a-z0-9]+)?(\\.autocommit)?\\.(up|down)\\.(sql)$`)\nif !re.MatchString(filename) { return fmt.Errorf(\"missing valid up/down direction in %q\", filename) }","typeGuard":null,"tryCatchPattern":"err := mb.Run(ctx)\nif err != nil {\n    if strings.Contains(err.Error(), \"unknown migration direction\") {\n        return fmt.Errorf(\"migration filename must end in .up.sql or .down.sql: %v\", err)\n    }\n    return err\n}","preventionTips":["Always end migration filenames with .up.sql or .down.sql","Lint filenames in CI to catch missing or misspelled direction segments","If forking the parser, keep the direction capture restricted to (up|down)"],"tags":["migrations","file-naming","database"],"backgroundTag":"invalid-migration-filename","analyzedSha":"4174065ffb052799890f7480f5360a877a67ffc1","analyzedAt":"2026-09-03T14:52:41.581Z","contentChangedAt":"2026-09-03T14:52:41.581Z","schemaVersion":2},"datasetVersion":"2026-09-10T17:17:09.494Z"}