{"record":{"id":"2eb3ec4bbcbfb78f","repo":"cilium/cilium","slug":"label-prefix-file-not-provided","errorCode":null,"errorMessage":"label prefix file not provided","messagePattern":"label prefix file not provided","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/labelsfilter/filter.go","lineNumber":266,"sourceCode":"\t}\n\n\tfor _, e := range expressions {\n\t\tp, err := parseLabelPrefix(e)\n\t\tif err != nil {\n\t\t\tmsg := fmt.Sprintf(\"BUG: Unable to parse default label prefix '%s': %s\", e, err)\n\t\t\tpanic(msg)\n\t\t}\n\t\tcfg.LabelPrefixes = append(cfg.LabelPrefixes, p)\n\t}\n\n\treturn cfg\n}\n\n// readLabelPrefixCfgFrom reads a label prefix configuration file from fileName.\n// return an error if fileName is empty, or if version is not supported.\nfunc readLabelPrefixCfgFrom(fileName string) (*labelPrefixCfg, error) {\n\tif fileName == \"\" {\n\t\treturn nil, fmt.Errorf(\"label prefix file not provided\")\n\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 == \"\" {","sourceCodeStart":248,"sourceCodeEnd":284,"githubUrl":"https://github.com/cilium/cilium/blob/ac7b90affa4baf0642e6685319d56907b3a73a6d/pkg/labelsfilter/filter.go#L248-L284","documentation":"readLabelPrefixCfgFrom reads a label prefix configuration file and explicitly rejects an empty file name before attempting to open it. ParseLabelPrefixCfg only calls it when file != \"\", so hitting this error means an empty/whitespace-only path was passed in despite the guard (or the function was invoked directly in tests).","triggerScenarios":"Passing a file path argument that is empty or consists only of whitespace to readLabelPrefixCfgFrom (via ParseLabelPrefixCfg when the guard was bypassed, e.g. file set to \"\" after trim, or direct calls).","commonSituations":"A flag like --label-prefix-file set to an empty string via Helm values/env interpolation that resolves to empty, or config plumbing that passes an unset variable.","solutions":["Provide a valid non-empty file path for the label prefix configuration","If no custom file is wanted, pass an empty file argument to ParseLabelPrefixCfg so it uses the built-in default list instead","Trace where the path comes from (flag/env/Helm value) and fix the empty interpolation"],"exampleFix":"// before\nfile := os.Getenv(\"CILIUM_LABEL_PREFIX_FILE\") // \"\"\nParseLabelPrefixCfg(logger, nil, nil, file) // label prefix file not provided\n// after\nif file := os.Getenv(\"CILIUM_LABEL_PREFIX_FILE\"); file != \"\" {\n    ParseLabelPrefixCfg(logger, nil, nil, file)\n} else {\n    ParseLabelPrefixCfg(logger, nil, nil, \"\")\n}","handlingStrategy":"validation","validationCode":"func requirePrefixFile(file string) error {\n    if strings.TrimSpace(file) == \"\" {\n        return errors.New(\"label prefix file path is empty; unset the flag or provide a path\")\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Guard env/flag interpolation so empty values don't produce empty paths","Pass \"\" explicitly to use built-in defaults instead of an empty path variable","Treat empty path as 'use defaults' in your own config plumbing"],"tags":["configuration","file-io","validation"],"backgroundTag":"missing-config-file-path","analyzedSha":"ac7b90affa4baf0642e6685319d56907b3a73a6d","analyzedAt":"2026-08-31T18:27:15.868Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}