{"record":{"id":"8007c0a5dc2904c3","repo":"cilium/cilium","slug":"invalid-destination-label-filter-w","errorCode":null,"errorMessage":"invalid destination label filter: %w","messagePattern":"invalid destination label filter: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/hubble/filters/labels.go","lineNumber":91,"sourceCode":"// LabelsFilter implements filtering based on labels\ntype LabelsFilter struct{}\n\n// OnBuildFilter builds a labels filter\nfunc (l *LabelsFilter) OnBuildFilter(ctx context.Context, ff *flowpb.FlowFilter) ([]FilterFunc, error) {\n\tvar fs []FilterFunc\n\n\tif ff.GetSourceLabel() != nil {\n\t\tslf, err := FilterByLabelSelectors(ff.GetSourceLabel(), sourceLabels)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"invalid source label filter: %w\", err)\n\t\t}\n\t\tfs = append(fs, slf)\n\t}\n\n\tif ff.GetDestinationLabel() != nil {\n\t\tdlf, err := FilterByLabelSelectors(ff.GetDestinationLabel(), destinationLabels)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"invalid destination label filter: %w\", err)\n\t\t}\n\t\tfs = append(fs, dlf)\n\t}\n\n\tif ff.GetNodeLabels() != nil {\n\t\tnlf, err := FilterByLabelSelectors(ff.GetNodeLabels(), nodeLabels)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"invalid node label filter: %w\", err)\n\t\t}\n\t\tfs = append(fs, nlf)\n\t}\n\n\treturn fs, nil\n}\n","sourceCodeStart":73,"sourceCodeEnd":106,"githubUrl":"https://github.com/cilium/cilium/blob/ac7b90affa4baf0642e6685319d56907b3a73a6d/pkg/hubble/filters/labels.go#L73-L106","documentation":"LabelsFilter.OnBuildFilter wraps errors from FilterByLabelSelectors when building the FlowFilter.destinationLabel filter. A malformed destination label selector causes this error, with the parse cause chained via %w so the exact problem is visible.","triggerScenarios":"Calling OnBuildFilter with FlowFilter.destinationLabel entries with invalid selector syntax, e.g. '=value', keys with invalid characters, or unparseable regex matchers.","commonSituations":"Typos in YAML label filter entries, copy-pasted selectors with stray characters, or labels copied with quotes/whitespace included.","solutions":["Correct the destination label selector to valid 'key=value' or supported match syntax.","Trim whitespace/quotes and validate selector parsing before constructing the FlowFilter.","Check the wrapped cause to identify which selector entry failed."],"exampleFix":"// before\nflowFilter.DestinationLabel = []string{\"=backend\"}\n// after\nflowFilter.DestinationLabel = []string{\"app=backend\"}","handlingStrategy":"validation","validationCode":"for _, sel := range flowFilter.GetDestinationLabel() {\n    k, v, ok := strings.Cut(sel, \"=\")\n    if !ok || k == \"\" || v == \"\" {\n        return fmt.Errorf(\"invalid destination label selector %q\", sel)\n    }\n}","typeGuard":"func isValidLabelSelector(s string) bool {\n    k, v, ok := strings.Cut(s, \"=\")\n    return ok && k != \"\" && v != \"\"\n}","tryCatchPattern":"ffs, err := filterBuilder.Build(ctx, flowFilter)\nif err != nil && strings.Contains(err.Error(), \"invalid destination label filter\") {\n    return fmt.Errorf(\"check destinationLabel selectors: %w\", err)\n}","preventionTips":["Validate 'key=value' syntax for every destinationLabel entry.","Trim quotes/whitespace from config-sourced selectors.","Reuse a single selector-validation helper for source, destination, and node labels."],"tags":["hubble","filters","kubernetes","labels"],"backgroundTag":"invalid-label-selector","analyzedSha":"ac7b90affa4baf0642e6685319d56907b3a73a6d","analyzedAt":"2026-08-31T18:27:15.868Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}