{"record":{"id":"98a1d243b50c3b6e","repo":"googleapis/mcp-toolbox","slug":"error-parsing-script-template-w","errorCode":null,"errorMessage":"error parsing script template: %w","messagePattern":"error parsing script template: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/internal/skills/generator.go","lineNumber":268,"sourceCode":"\tOptionalVars   []string\n}\n\n// generateScriptContent creates the content for a Node.js wrapper script.\n// This script invokes the toolbox CLI with the appropriate configuration\n// (using a generated config) and arguments to execute the specific tool.\nfunc generateScriptContent(name string, configArgs string, licenseHeader string, mode string, version string, optionalVars []string) (string, error) {\n\tdata := scriptData{\n\t\tName:           name,\n\t\tConfigArgs:     configArgs,\n\t\tLicenseHeader:  licenseHeader,\n\t\tInvocationMode: mode,\n\t\tToolboxVersion: version,\n\t\tOptionalVars:   optionalVars,\n\t}\n\n\ttmpl, err := template.New(\"script\").Parse(nodeScriptTemplate)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"error parsing script template: %w\", err)\n\t}\n\n\tvar buf strings.Builder\n\tif err := tmpl.Execute(&buf, data); err != nil {\n\t\treturn \"\", fmt.Errorf(\"error executing script template: %w\", err)\n\t}\n\n\treturn buf.String(), nil\n}\n\n// formatParameters converts a list of parameter manifests into a formatted JSON schema string.\n// This schema is used in the skill documentation to describe the input parameters for a tool.\nfunc formatParameters(params []parameters.ParameterManifest, envVars map[string]string) (string, error) {\n\tif len(params) == 0 {\n\t\treturn \"\", nil\n\t}\n\n\tvar sb strings.Builder","sourceCodeStart":250,"sourceCodeEnd":286,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/cmd/internal/skills/generator.go#L250-L286","documentation":"`generateScriptContent` throws \"error parsing script template: %w\" when `template.New(\"script\").Parse(nodeScriptTemplate)` fails for the embedded Node.js wrapper script template. Like the markdown template error, the template text is embedded in the binary, so this indicates a syntax error in the shipped `nodeScriptTemplate` constant (malformed Go template actions) rather than user configuration. The wrapped text/template error identifies the exact syntax problem.","triggerScenarios":"Calling `generateScriptContent` (via `run` or an anonymous test helper) with a `nodeScriptTemplate` containing invalid template syntax: unbalanced `{{`/`}}`, unknown functions, or invalid pipelines — e.g. after someone edited the script template and mixed JavaScript braces with template actions incorrectly.","commonSituations":"A developer edited the embedded node script (adding JS objects with `{{`-like sequences or template actions) and broke parsing; a fork or patch applied to generator.go corrupted the template string; build artifacts stale relative to source.","solutions":["Read the wrapped error — it gives the line/column of the bad template action","Inspect `nodeScriptTemplate` in cmd/internal/skills/generator.go for unbalanced `{{ }}` or raw `{`/`}` conflicts with template actions (use `{{\"{\"}}` or backtick-safe literals)","Rebuild with `go build -o toolbox` so the embedded template matches source","Add/keep a unit test covering generateScriptContent to catch template syntax regressions"],"exampleFix":"// before: raw JS object literal inside a template action confuses parsing\n// const cfg = {{ .Config };\n// after: valid action with proper braces\n// const cfg = {{ .Config }};","handlingStrategy":"try-catch","validationCode":"// Fail fast on template syntax in tests/init\nfunc validateScriptTemplate(t string) error {\n\t_, err := template.New(\"script\").Parse(t)\n\treturn err\n}","typeGuard":null,"tryCatchPattern":"tmpl, err := template.New(\"script\").Parse(nodeScriptTemplate)\nif err != nil {\n\treturn \"\", fmt.Errorf(\"error parsing script template: %w\", err)\n}","preventionTips":["Be careful embedding raw JS braces in Go templates — escape `{`/`}` literals that look like actions","Add a parse-time unit test for nodeScriptTemplate","Run gofmt/go test after editing the embedded script template","Rebuild the binary; the template is compiled in via go:embed"],"tags":["go","template","text-template","codegen","nodejs"],"backgroundTag":"template-parse-error","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"}