{"record":{"id":"6f9f4dd5d5de4080","repo":"ory/hydra","slug":"could-not-execute-migration-template-s","errorCode":null,"errorMessage":"could not execute migration template %s","messagePattern":"could not execute migration template (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"oryx/popx/migration_content.go","lineNumber":45,"sourceCode":"\t\t\terr = t.Execute(&bb, struct {\n\t\t\t\tIsSQLite       bool\n\t\t\t\tIsCockroach    bool\n\t\t\t\tIsMySQL        bool\n\t\t\t\tIsMariaDB      bool\n\t\t\t\tIsPostgreSQL   bool\n\t\t\t\tDialectDetails *pop.ConnectionDetails\n\t\t\t\tParameters     map[string]interface{}\n\t\t\t}{\n\t\t\t\tIsSQLite:       c.Dialect.Name() == \"sqlite3\",\n\t\t\t\tIsCockroach:    c.Dialect.Name() == \"cockroach\",\n\t\t\t\tIsMySQL:        c.Dialect.Name() == \"mysql\",\n\t\t\t\tIsMariaDB:      c.Dialect.Name() == \"mariadb\",\n\t\t\t\tIsPostgreSQL:   dbal.IsPostgresCompatible(c.Dialect.Name()),\n\t\t\t\tDialectDetails: c.Dialect.Details(),\n\t\t\t\tParameters:     params,\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn \"\", errors.Wrapf(err, \"could not execute migration template %s\", mf.Path)\n\t\t\t}\n\t\t\tcontent = bb.String()\n\t\t} else {\n\t\t\tcontent = string(b)\n\t\t}\n\n\t\treturn content, nil\n\t}\n}\n","sourceCodeStart":27,"sourceCodeEnd":55,"githubUrl":"https://github.com/ory/hydra/blob/4174065ffb052799890f7480f5360a877a67ffc1/oryx/popx/migration_content.go#L27-L55","documentation":"After parsing, the template is executed with a data struct (IsSQLite, IsCockroach, IsMySQL, IsMariaDB, IsPostgreSQL, DialectDetails, Parameters). If t.Execute fails while rendering the migration for the current dialect, the error is wrapped with 'could not execute migration template %s'.","triggerScenarios":"A template referencing a field/function missing from the execution data struct (e.g. {{ .Foo }}), or a custom SQLTemplateFuncs function returning an error during Execute for a specific dialect.","commonSituations":"Renaming struct fields without updating migration templates; a dialect-specific helper failing; typos in field names like {{ .IsPostgres }} instead of {{ .IsPostgreSQL }}.","solutions":["Check the template references only provided fields: IsSQLite, IsCockroach, IsMySQL, IsMariaDB, IsPostgreSQL, DialectDetails, Parameters","Fix field-name typos in the migration template","Inspect the wrapped cause for custom function failures and fix that function","Render the template locally with a small Go snippet against the same data to reproduce"],"exampleFix":"// before (migration template)\n{{ .IsPostgres }}\n// after\n{{ .IsPostgreSQL }}","handlingStrategy":"validation","validationCode":"// Execute the template with representative data before deploying\nfunc templateExecutes(path string) error {\n  b, _ := os.ReadFile(path)\n  t, err := template.New(\"check\").Funcs(popx.SQLTemplateFuncs).Parse(string(b))\n  if err != nil { return err }\n  return t.Execute(io.Discard, map[string]any{\n    \"IsSQLite\": true, \"IsCockroach\": false, \"IsMySQL\": false,\n    \"IsMariaDB\": false, \"IsPostgreSQL\": false, \"DialectDetails\": nil, \"Parameters\": nil,\n  })\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Reference only fields present in the execution data struct","Test templated migrations against every dialect your app supports","Update templates whenever the data struct fields change","Keep dialect branches ({{ if .IsMySQL }}) individually tested"],"tags":["migrations","go","templates","sql"],"backgroundTag":"template-execute-error","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"}