{"record":{"id":"bf2a8e94aab5c821","repo":"argoproj/argo-workflows","slug":"s-bf2a8e","errorCode":null,"errorMessage":"%s","messagePattern":"%s","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"util/telemetry/builder/validate.go","lineNumber":14,"sourceCode":"package main\n\nimport (\n\t\"fmt\"\n\t\"slices\"\n\t\"strings\"\n)\n\ntype validator struct {\n\terrors []error\n}\n\nfunc (v *validator) recordError(format string, args ...any) {\n\tv.errors = append(v.errors, fmt.Errorf(format, args...))\n}\n\nfunc (v *validator) valid() bool {\n\treturn len(v.errors) == 0\n}\n\nfunc (v *validator) printErrors() {\n\tfor _, err := range v.errors {\n\t\tfmt.Println(err)\n\t}\n\tfmt.Printf(\"%d validation errors\\n\", len(v.errors))\n}\n\nfunc (v *validator) telemetryAttributes(items []hasCommon, attributes *attributesList, context string) {\n\tfor _, item := range items {\n\t\tc := item.Common()\n\t\tfor _, attribute := range c.Attributes {\n\t\t\tif getAttribByName(attribute.Name, attributes) == nil {","sourceCodeStart":1,"sourceCodeEnd":32,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/util/telemetry/builder/validate.go#L1-L32","documentation":"The telemetry builder's validator accumulates validation errors via recordError(format, args...) using fmt.Errorf. The message is whatever format string the calling validator passed — describing a problem found while validating telemetry attributes, metrics, buckets, descriptions, or span parentage. These errors are collected and reported together when the generator's validation pass finds the telemetry definitions inconsistent.","triggerScenarios":"Running the telemetry builder's validation where a metric/attribute definition violates a rule: e.g. missing description, invalid bucket definitions, duplicate instrument names, or span-parentage violations — each calls v.recordError with a specific message.","commonSituations":"Adding a new metric to the telemetry registry with an incomplete definition; renaming an attribute but missing a usage site; invalid histogram bucket config; failing validation in CI during make codegen.","solutions":["Read the recorded validation message — it states exactly which metric/attribute/definition is invalid.","Fix the offending definition in the telemetry registry (util/telemetry package) — description, buckets, or attribute usage.","Rerun `go run ./util/telemetry/builder` (or make codegen) until validation passes.","Check for duplicates: instrument names and attribute keys must be unique across the registry."],"exampleFix":"// before\nMetric{Name: \"pod_count\"} // no description -> validator.recordError\n// after\nMetric{Name: \"pod_count\", Description: \"Number of pods managed by the controller\", Help: \"...\"}","handlingStrategy":"validation","validationCode":"// pre-check registry before the builder's validate pass\nnames := map[string]bool{}\nfor _, m := range metrics {\n    if m.Description == \"\" { return fmt.Errorf(\"metric %s missing description\", m.Name) }\n    if names[m.Name] { return fmt.Errorf(\"duplicate metric %s\", m.Name) }\n    names[m.Name] = true\n}","typeGuard":null,"tryCatchPattern":"if err := runBuilder(); err != nil {\n    // validator errors are collected and reported together; read all messages\n    logger.Info(ctx, err.Error())\n    return err\n}","preventionTips":["Give every new metric/attribute a description and help text at definition time.","Keep instrument names and attribute keys unique in the registry.","Run make codegen (which validates) before committing telemetry changes.","Review validation messages as a batch — multiple errors are reported together."],"tags":["validation","telemetry","codegen","metrics"],"backgroundTag":"telemetry-definition-validation-failed","analyzedSha":"35bff19146f5a6ada77468c431f2624bd577e373","analyzedAt":"2026-09-03T19:34:35.908Z","contentChangedAt":"2026-09-03T19:34:35.908Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}