{"record":{"id":"6b98838a08a8cb46","repo":"ory/hydra","slug":"error-processing-s","errorCode":null,"errorMessage":"error processing %s","messagePattern":"error processing (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"oryx/popx/migration_box.go","lineNumber":196,"sourceCode":"}\n\n// NewMigrationBox creates a new migration box.\nfunc NewMigrationBox(dir fs.FS, c *pop.Connection, l *logrusx.Logger, opts ...MigrationBoxOption) (*MigrationBox, error) {\n\tmb := &MigrationBox{\n\t\tc:                c,\n\t\tl:                l,\n\t\tmigrationContent: ParameterizedMigrationContent(nil),\n\t}\n\n\tfor _, o := range opts {\n\t\to(mb)\n\t}\n\n\ttxRunner := func(b []byte) func(Migration, *pop.Connection) error {\n\t\treturn func(mf Migration, c *pop.Connection) error {\n\t\t\tcontent, err := mb.migrationContent(mf, c, b, true)\n\t\t\tif err != nil {\n\t\t\t\treturn errors.Wrapf(err, \"error processing %s\", mf.Path)\n\t\t\t}\n\t\t\tif isMigrationEmpty(content) {\n\t\t\t\tl.WithField(\"migration\", mf.Path).Trace(\"This is usually ok - ignoring migration because content is empty. This is ok!\")\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\tvar q queryExecutor = c.Store.SQLDB()\n\t\t\tif c.TX != nil {\n\t\t\t\tq = c.TX\n\t\t\t}\n\n\t\t\tif _, err = q.Exec(content); err != nil {\n\t\t\t\treturn errors.Wrapf(err, \"error executing %s, sql: %s\", mf.Path, content)\n\t\t\t}\n\t\t\treturn nil\n\t\t}\n\t}\n","sourceCodeStart":178,"sourceCodeEnd":214,"githubUrl":"https://github.com/ory/hydra/blob/4174065ffb052799890f7480f5360a877a67ffc1/oryx/popx/migration_box.go#L178-L214","documentation":"During migration execution (MigrationBox.Run/Exec), each migration's content is prepared via mb.migrationContent. If content preparation fails, the error is wrapped with \"error processing <path>\" (oryx/popx/migration_box.go:196) so the developer knows which migration file could not be processed. The underlying error (parse failure, fizz template error, etc.) is preserved in the wrap chain.","triggerScenarios":"mb.migrationContent(mf, c, b, true) returns an error for a migration file while running migrations from a directory — e.g. invalid SQL/fizz template content that cannot be compiled for the connection's dialect.","commonSituations":"Corrupted or malformed migration file content embedded in the binary; fizz template syntax errors; a migration written for a dialect incompatible with the connected database.","solutions":["Read the wrapped cause in the error chain to identify the real parse/compile failure in the migration at the reported path","Fix or remove the broken migration file and rebuild/redeploy","Verify the migration content is valid for the connected dialect"],"exampleFix":"// before (malformed fizz template)\nCREATE TABLE %%{{ users }}; SELECT FROM\n// after (valid SQL)\nCREATE TABLE users (id serial primary key);","handlingStrategy":"try-catch","validationCode":"// validate migration content parses before running migrations\ncontent, err := mb.MigrationContent(mf, conn, raw, true)\nif err != nil { return fmt.Errorf(\"migration %s has invalid content: %w\", mf.Path, err) }","typeGuard":null,"tryCatchPattern":"err := mb.Exec(ctx, conn)\nif err != nil {\n    // the wrap chain names the file: 'error processing <path>' plus the cause\n    log.Printf(\"migration run failed: %+v\", err)\n    return err\n}","preventionTips":["Test migrations against a scratch database in CI before production runs","Keep migration files in version control and validate on build","Inspect the full wrap chain (%+v) to find the underlying parse/template error"],"tags":["migrations","database","sql","execution"],"backgroundTag":"migration-execution-failed","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"}