{"record":{"id":"f3ecb6070f2c82ec","repo":"gohugoio/hugo","slug":"template-s-d-s","errorCode":null,"errorMessage":"template: %s:%d: %s","messagePattern":"template: (.+?):(.+?): (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tpl/internal/go_templates/texttemplate/parse/parse.go","lineNumber":176,"sourceCode":"\t}\n\ttext := tree.text[:pos]\n\tbyteNum := strings.LastIndex(text, \"\\n\")\n\tif byteNum == -1 {\n\t\tbyteNum = pos // On first line.\n\t} else {\n\t\tbyteNum++ // After the newline.\n\t\tbyteNum = pos - byteNum\n\t}\n\tlineNum := 1 + strings.Count(text, \"\\n\")\n\tcontext = n.String()\n\treturn fmt.Sprintf(\"%s:%d:%d\", tree.ParseName, lineNum, byteNum), context\n}\n\n// errorf formats the error and terminates processing.\nfunc (t *Tree) errorf(format string, args ...any) {\n\tt.Root = nil\n\tformat = fmt.Sprintf(\"template: %s:%d: %s\", t.ParseName, t.token[0].line, format)\n\tpanic(fmt.Errorf(format, args...))\n}\n\n// error terminates processing.\nfunc (t *Tree) error(err error) {\n\tt.errorf(\"%s\", err)\n}\n\n// expect consumes the next token and guarantees it has the required type.\nfunc (t *Tree) expect(expected itemType, context string) item {\n\ttoken := t.nextNonSpace()\n\tif token.typ != expected {\n\t\tt.unexpected(token, context)\n\t}\n\treturn token\n}\n\n// expectOneOf consumes the next token and guarantees it has one of the required types.\nfunc (t *Tree) expectOneOf(expected1, expected2 itemType, context string) item {","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/tpl/internal/go_templates/texttemplate/parse/parse.go#L158-L194","documentation":"This is the universal prefix the parser attaches to every parse error: 'template: <ParseName>:<line>: <message>'. It is the formatting wrapper in Tree.errorf (parse.go:173-177), not a distinct error; the specific failure (704, 705, 706, undefined function, unexpected token, etc.) is interpolated into the trailing %s.","triggerScenarios":"Any syntax or parse-time error in a Go template: unbalanced delimiters, missing {{end}}, unclosed action, bad node, undefined function reference during parse.","commonSituations":"Authoring typo in a template; forgetting to close a range/with/if block; this carrier string precedes nearly every build-time template parse error.","solutions":["Read the file:line:column in the formatted message to locate the actual source position.","Fix the underlying specific error described after the line number.","Run a template linter or formatter to catch structural mistakes early."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"_, err := template.New(name).Parse(text)\nif err != nil {\n    // err string starts with \"template: <name>:<line>:\"\n    log.Printf(\"template parse failed: %v\", err)\n    return err\n}","preventionTips":["Always check the error return from template.Parse/Execute.","Read the embedded file:line to locate the true source of any parse failure."],"tags":["template","go","parse","diagnostic","error-wrapper"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}