cilium/cilium · error

label prefix file not provided

Error message

label prefix file not provided

What it means

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).

Source

Thrown at pkg/labelsfilter/filter.go:266

	}

	for _, e := range expressions {
		p, err := parseLabelPrefix(e)
		if err != nil {
			msg := fmt.Sprintf("BUG: Unable to parse default label prefix '%s': %s", e, err)
			panic(msg)
		}
		cfg.LabelPrefixes = append(cfg.LabelPrefixes, p)
	}

	return cfg
}

// readLabelPrefixCfgFrom reads a label prefix configuration file from fileName.
// return an error if fileName is empty, or if version is not supported.
func readLabelPrefixCfgFrom(fileName string) (*labelPrefixCfg, error) {
	if fileName == "" {
		return nil, fmt.Errorf("label prefix file not provided")
	}

	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 == "" {

View on GitHub (pinned to ac7b90affa)

Solutions

  1. Provide a valid non-empty file path for the label prefix configuration
  2. If no custom file is wanted, pass an empty file argument to ParseLabelPrefixCfg so it uses the built-in default list instead
  3. Trace where the path comes from (flag/env/Helm value) and fix the empty interpolation

Example fix

// before
file := os.Getenv("CILIUM_LABEL_PREFIX_FILE") // ""
ParseLabelPrefixCfg(logger, nil, nil, file) // label prefix file not provided
// after
if file := os.Getenv("CILIUM_LABEL_PREFIX_FILE"); file != "" {
    ParseLabelPrefixCfg(logger, nil, nil, file)
} else {
    ParseLabelPrefixCfg(logger, nil, nil, "")
}
Defensive patterns

Strategy: validation

Validate before calling

func requirePrefixFile(file string) error {
    if strings.TrimSpace(file) == "" {
        return errors.New("label prefix file path is empty; unset the flag or provide a path")
    }
    return nil
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of cilium/cilium@ac7b90affa (2026-08-31). Data as JSON: /api/errors/2eb3ec4bbcbfb78f. Report an issue: GitHub.