cilium/cilium · error
invalid label prefix file: prefix was empty
Error message
invalid label prefix file: prefix was empty
What it means
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.
Source
Thrown at pkg/labelsfilter/filter.go:285
}
f, err := os.Open(fileName)
if err != nil {
return nil, err
}
defer f.Close()
lpc := labelPrefixCfg{}
err = json.NewDecoder(f).Decode(&lpc)
if err != nil {
return nil, err
}
if lpc.Version != LPCfgFileVersion {
return nil, fmt.Errorf("unsupported version %d", lpc.Version)
}
for _, lp := range lpc.LabelPrefixes {
if lp.Prefix == "" {
return nil, fmt.Errorf("invalid label prefix file: prefix was empty")
}
if lp.Source == "" {
return nil, fmt.Errorf("invalid label prefix file: source was empty")
}
if !lp.Ignore {
lpc.whitelist = true
}
}
return &lpc, nil
}
func (cfg *labelPrefixCfg) filterLabels(lbls labels.Labels) (identityLabels, informationLabels labels.Labels) {
if len(lbls) == 0 {
return nil, nil
}
validLabelPrefixesMU.RLock()
defer validLabelPrefixesMU.RUnlock()View on GitHub (pinned to ac7b90affa)
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
Example fix
// before
{"version":1,"labelPrefixes":[{"prefix":"","source":"k8s"}]}
// after
{"version":1,"labelPrefixes":[{"prefix":"k8s:","source":"k8s"}]} Defensive patterns
Strategy: validation
Validate before calling
func validatePrefixEntries(data []byte) error {
var cfg struct{ LabelPrefixes []struct{ Prefix string `json:"prefix"` } `json:"labelPrefixes"` }
if err := json.Unmarshal(data, &cfg); err != nil { return err }
for i, lp := range cfg.LabelPrefixes {
if lp.Prefix == "" { return fmt.Errorf("entry %d: empty prefix", i) }
}
return nil
} Prevention
- 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
When it happens
Trigger: 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"}]}.
Common situations: 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.
Related errors
- invalid label prefix file: source was empty
- invalid Label: '%s' does not contain label key
- invalid label source %q, prefix %q
- unsupported version %d
- unable to parse CNI configuration %q: %w
AI-assisted analysis of cilium/cilium@ac7b90affa (2026-08-31).
Data as JSON: /api/errors/6292c3e9df93b7f1.
Report an issue: GitHub.