{"record":{"id":"a7d6a5ea765f21f6","repo":"googleapis/mcp-toolbox","slug":"error-creating-go-template-s","errorCode":null,"errorMessage":"error creating go template %s","messagePattern":"error creating go template (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/util/parameters/parameters.go","lineNumber":291,"sourceCode":"\t\t}\n\t\tresultParamValues = append(resultParamValues, ParamValue{Name: k, Value: v})\n\t}\n\treturn resultParamValues, nil\n}\n\nfunc ResolveTemplateParams(templateParams Parameters, originalStatement string, paramsMap map[string]any) (string, error) {\n\ttemplateParamsValues, err := GetParams(templateParams, paramsMap)\n\ttemplateParamsMap := templateParamsValues.AsMap()\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"error getting template params %s\", err)\n\t}\n\n\tfuncMap := template.FuncMap{\n\t\t\"array\": ConvertArrayParamToString,\n\t}\n\tt, err := template.New(\"statement\").Funcs(funcMap).Parse(originalStatement)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"error creating go template %s\", err)\n\t}\n\tvar result bytes.Buffer\n\terr = t.Execute(&result, templateParamsMap)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"error executing go template %s\", err)\n\t}\n\n\tmodifiedStatement := result.String()\n\treturn modifiedStatement, nil\n}\n\n// ProcessParameters concatenate templateParameters and parameters from a tool.\n// It returns a list of concatenated parameters, concatenated Toolbox manifest, and concatenated MCP Manifest.\nfunc ProcessParameters(templateParams Parameters, params Parameters) (Parameters, []ParameterManifest, error) {\n\tallParameters := slices.Concat(params, templateParams)\n\n\t// verify no duplicate parameter names\n\terr := CheckDuplicateParameters(allParameters)","sourceCodeStart":273,"sourceCodeEnd":309,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/util/parameters/parameters.go#L273-L309","documentation":"ResolveTemplateParams wraps text/template's Parse failure with this message. The configured statement/URL/message is not syntactically valid Go template syntax — typically unbalanced braces or invalid template tokens. This fails before any parameter values are substituted.","triggerScenarios":"A configured statement containing malformed template syntax: unclosed {{, stray braces, invalid pipeline syntax, or syntax from other template languages (Jinja/Handlebars) that Go's parser rejects.","commonSituations":"Hand-edited SQL or YAML introducing literal {{; copying templates from non-Go docs; leftover {{ limit }} style syntax from Jinja; accidental use of undefined helper names at parse time.","solutions":["Locate the {{...}} expression cited in the wrapped error and balance/fix the braces.","Use only Go template syntax: {{.paramName}} and the provided {{array .paramName}} helper.","Escape or remove literal {{ sequences in the statement that weren't meant as templates.","Validate the statement offline with template.New(\"statement\").Parse before deploying the config."],"exampleFix":"# before (Jinja-style, invalid in Go)\nSELECT * FROM t LIMIT {{ limit }}\n\n# after (Go template syntax)\nSELECT * FROM t LIMIT {{.limit}}","handlingStrategy":"validation","validationCode":"if _, err := template.New(\"s\").Funcs(template.FuncMap{\"array\": params.ConvertArrayParamToString}).Parse(stmt); err != nil {\n    return fmt.Errorf(\"invalid template in statement: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"out, err := params.ResolveTemplateParams(tp, stmt, m)\nif err != nil && strings.Contains(err.Error(), \"error creating go template\") {\n    return fmt.Errorf(\"statement has invalid Go template syntax: %w\", err)\n}","preventionTips":["Parse-validate every statement in CI before deploying configs.","Use Go template syntax only — no Jinja/Handlebars constructs.","Escape literal braces in SQL/URLs that shouldn't be templated.","Keep a lint rule or test that runs Parse over all configured statements."],"tags":["templates","go-templates","configuration"],"backgroundTag":"invalid-template-syntax","analyzedSha":"8cc6e09de2ad7b8bffc77751799585a1401a48eb","analyzedAt":"2026-09-05T01:10:36.887Z","contentChangedAt":"2026-09-05T01:10:36.887Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}