{"record":{"id":"f1c5bd3f75e7d839","repo":"argoproj/argo-workflows","slug":"s","errorCode":null,"errorMessage":"%s","messagePattern":"%s","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"util/telemetry/builder/common.go","lineNumber":57,"sourceCode":"\terr = attributeHeaderTmpl.Execute(f, map[string]string{\"Banner\": generatedBanner, \"Filename\": filepath.Base(filename)})\n\tif err != nil {\n\t\treturn err\n\t}\n\tfmt.Fprintf(f, \"const(\\n\")\n\tfor _, attrib := range *attributes {\n\t\tfmt.Fprintf(f, \"\\tAttrib%s string = `%s`\\n\", attrib.Name, attrib.displayName())\n\t}\n\tfmt.Fprintf(f, \")\\n\")\n\treturn nil\n}\n\nfunc goFmtFile(filename string) error {\n\tcmd := exec.Command(\"go\", \"fmt\", filename)\n\tvar stderr bytes.Buffer\n\tcmd.Stderr = &stderr\n\t_, err := cmd.Output()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"%s\", stderr.String())\n\t}\n\treturn nil\n}\n","sourceCodeStart":39,"sourceCodeEnd":61,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/util/telemetry/builder/common.go#L39-L61","documentation":"goFmtFile runs `go fmt <filename>` on generated telemetry Go files and returns the captured stderr as the error. The error is therefore whatever the Go toolchain printed — typically 'go: cannot find main module', 'no such file', or a syntax error in the generated file. This is a code-generation-time (build-time) failure, only seen when running the telemetry builder generator.","triggerScenarios":"createAttributesGo, createMetricsHelpersGo, createMetricsListGo, or createTracingGo generate a file and goFmtFile invokes `go fmt` on it while either the generated file has invalid syntax, go is missing from PATH, or the command runs outside a Go module (no go.mod).","commonSituations":"Running the generator from a directory without go.mod; a broken Go installation or missing go binary in CI images; edits to generator templates that emit syntactically invalid Go; running `go run ./util/telemetry/builder` outside the repo root.","solutions":["Read the returned stderr text — it names the Go toolchain problem; fix that first.","Run the builder from the repo root where go.mod exists (cd argo-workflows && go run ./util/telemetry/builder).","Check the generated file named in the message for syntax errors in your generator templates.","Ensure `go` (a supported version) is on PATH in your environment/CI image."],"exampleFix":"// before (run from wrong dir)\ncd util/telemetry/builder && go run .\n// failed to fmt: go: cannot find main module\n// after\ncd /path/to/argo-workflows && go run ./util/telemetry/builder","handlingStrategy":"validation","validationCode":"// before running the builder\nif _, err := exec.LookPath(\"go\"); err != nil { return errors.New(\"go not on PATH\") }\nif _, err := os.Stat(\"go.mod\"); err != nil { return errors.New(\"run the builder from the repo root\") }","typeGuard":null,"tryCatchPattern":"if err := goFmtFile(filename); err != nil {\n    // err text IS the go toolchain stderr; surface verbatim\n    return fmt.Errorf(\"gofmt failed for %s: %s\", filename, err)\n}","preventionTips":["Run codegen from the repository root with go.mod present.","Ensure a supported Go toolchain is installed in CI images.","After editing generator templates, gofmt the emitted output locally first.","Run make codegen -B rather than invoking the builder ad hoc."],"tags":["codegen","gofmt","build","telemetry"],"backgroundTag":"gofmt-toolchain-failure","analyzedSha":"35bff19146f5a6ada77468c431f2624bd577e373","analyzedAt":"2026-09-03T19:34:35.908Z","contentChangedAt":"2026-09-03T19:34:35.908Z","schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}