{"record":{"id":"08a5f444481ebbe6","repo":"hashicorp/nomad","slug":"format-error-v","errorCode":null,"errorMessage":"format error: %v","messagePattern":"format error: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/plugin_status_csi.go","lineNumber":90,"sourceCode":"\n\tstr, err := c.csiFormatPlugin(plug)\n\tif err != nil {\n\t\tc.Ui.Error(fmt.Sprintf(\"Error formatting plugin: %s\", err))\n\t\treturn 1\n\t}\n\n\tc.Ui.Output(str)\n\treturn 0\n}\n\nfunc (c *PluginStatusCommand) csiFormatPlugins(plugs []*api.CSIPluginListStub) (string, error) {\n\t// Sort the output by quota name\n\tsort.Slice(plugs, func(i, j int) bool { return plugs[i].ID < plugs[j].ID })\n\n\tif c.json || len(c.template) > 0 {\n\t\tout, err := Format(c.json, c.template, plugs)\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"format error: %v\", err)\n\t\t}\n\t\treturn out, nil\n\t}\n\n\trows := make([]string, len(plugs)+1)\n\trows[0] = \"ID|Provider|Controllers Healthy/Expected|Nodes Healthy/Expected\"\n\tfor i, p := range plugs {\n\t\trows[i+1] = fmt.Sprintf(\"%s|%s|%d/%d|%d/%d\",\n\t\t\tlimit(p.ID, c.length),\n\t\t\tp.Provider,\n\t\t\tp.ControllersHealthy,\n\t\t\tp.ControllersExpected,\n\t\t\tp.NodesHealthy,\n\t\t\tp.NodesExpected,\n\t\t)\n\t}\n\treturn formatList(rows), nil\n}","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/plugin_status_csi.go#L72-L108","documentation":"When `nomad plugin status` with CSI plugins is run with -json or -template, csiFormatPlugins renders the plugin list via the shared Format helper. If JSON marshaling or template execution fails, the error is wrapped as \"format error\".","triggerScenarios":"Running `nomad plugin status -json` or `-template '...'` where the template has invalid syntax, references fields that don't exist on []api.CSIPlugin, or JSON output cannot be produced.","commonSituations":"Typos in template field paths (e.g. {{.Plugins}} when the data is a plain list), wrong template functions, or copying Consul/Vault templates that expect different data shapes.","solutions":["Test the template with plain output first (`nomad plugin status <id>`) to confirm the data shape, then fix template field names.","Validate template syntax — missing {{end}}, bad pipelines, undefined functions.","Use -json alone to see the exact structure before writing a template.","Keep the wrapped error text after \"format error:\" to pinpoint the template line."],"exampleFix":"// before\nnomad plugin status -template '{{range .Plugins}}{{.ID}}{{end}}'\n\n// after\nnomad plugin status -template '{{range .}}{{.ID}}{{end}}'","handlingStrategy":"validation","validationCode":"// render with -json first to confirm data shape before templating\nconst data = execSync('nomad plugin status -json').toString();\nconst plugins = JSON.parse(data); // must be an array of CSIPlugin\nif (!Array.isArray(plugins)) throw new Error('expected plugin list');","typeGuard":null,"tryCatchPattern":"try { out = csiFormatPlugins(plugs) } catch (e) { if (String(e).startsWith('format error')) { console.error('Template invalid for plugin list; test with -json first:', e.message); } throw e; }","preventionTips":["Always inspect the -json output shape before writing a -template.","Remember list-format commands receive an array (use {{range .}}).","Lint Go templates for balanced {{range}}/{{end}} pairs."],"tags":["cli","template","json","formatting","nomad"],"backgroundTag":"template-render-failed","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}