{"record":{"id":"6292c3e9df93b7f1","repo":"cilium/cilium","slug":"invalid-label-prefix-file-prefix-was-empty","errorCode":null,"errorMessage":"invalid label prefix file: prefix was empty","messagePattern":"invalid label prefix file: prefix was empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/labelsfilter/filter.go","lineNumber":285,"sourceCode":"\t}\n\n\tf, err := os.Open(fileName)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer f.Close()\n\n\tlpc := labelPrefixCfg{}\n\terr = json.NewDecoder(f).Decode(&lpc)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif lpc.Version != LPCfgFileVersion {\n\t\treturn nil, fmt.Errorf(\"unsupported version %d\", lpc.Version)\n\t}\n\tfor _, lp := range lpc.LabelPrefixes {\n\t\tif lp.Prefix == \"\" {\n\t\t\treturn nil, fmt.Errorf(\"invalid label prefix file: prefix was empty\")\n\t\t}\n\t\tif lp.Source == \"\" {\n\t\t\treturn nil, fmt.Errorf(\"invalid label prefix file: source was empty\")\n\t\t}\n\t\tif !lp.Ignore {\n\t\t\tlpc.whitelist = true\n\t\t}\n\t}\n\treturn &lpc, nil\n}\n\nfunc (cfg *labelPrefixCfg) filterLabels(lbls labels.Labels) (identityLabels, informationLabels labels.Labels) {\n\tif len(lbls) == 0 {\n\t\treturn nil, nil\n\t}\n\n\tvalidLabelPrefixesMU.RLock()\n\tdefer validLabelPrefixesMU.RUnlock()","sourceCodeStart":267,"sourceCodeEnd":303,"githubUrl":"https://github.com/cilium/cilium/blob/ac7b90affa4baf0642e6685319d56907b3a73a6d/pkg/labelsfilter/filter.go#L267-L303","documentation":"Every entry in the label prefix file's labelPrefixes array must carry a non-empty 'prefix' string; an entry with an empty prefix would match nothing meaningful, so readLabelPrefixCfgFrom rejects the whole file with this error.","triggerScenarios":"A JSON file parsed by readLabelPrefixCfgFrom containing an element in \"labelPrefixes\" with \"prefix\":\"\" or a missing prefix field, e.g. {\"version\":1,\"labelPrefixes\":[{\"source\":\"k8s\"}]}.","commonSituations":"Empty Helm template values rendering into the ConfigMap, trailing commas creating null/empty entries, or copy-paste of an entry where the prefix was deleted but the entry kept.","solutions":["Fill in a non-empty \"prefix\" for every entry in the labelPrefixes array","Remove empty/null placeholder entries from the array","Check the Helm/templating pipeline that generates the file for empty values"],"exampleFix":"// before\n{\"version\":1,\"labelPrefixes\":[{\"prefix\":\"\",\"source\":\"k8s\"}]}\n// after\n{\"version\":1,\"labelPrefixes\":[{\"prefix\":\"k8s:\",\"source\":\"k8s\"}]}","handlingStrategy":"validation","validationCode":"func validatePrefixEntries(data []byte) error {\n    var cfg struct{ LabelPrefixes []struct{ Prefix string `json:\"prefix\"` } `json:\"labelPrefixes\"` }\n    if err := json.Unmarshal(data, &cfg); err != nil { return err }\n    for i, lp := range cfg.LabelPrefixes {\n        if lp.Prefix == \"\" { return fmt.Errorf(\"entry %d: empty prefix\", i) }\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remove null/empty placeholder entries from labelPrefixes","Check rendered Helm templates for empty prefix values","Validate the whole file with a JSON schema before applying"],"tags":["configuration","json","validation","labels"],"backgroundTag":"config-schema-validation-failed","analyzedSha":"ac7b90affa4baf0642e6685319d56907b3a73a6d","analyzedAt":"2026-08-31T18:27:15.868Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}