jaegertracing/jaeger · error
cannot load config file %s: %w
Error message
cannot load config file %s: %w
What it means
TryLoadConfigFile reads the --config-file value from Viper and calls v.ReadInConfig(); any read/parse failure is wrapped as "cannot load config file %s" with the file path embedded. Viper returns errors for missing files, unsupported extensions, and invalid syntax (YAML/JSON parse errors).
Source
Thrown at cmd/internal/flags/flags.go:35
const (
logLevel = "log-level"
logEncoding = "log-encoding" // json or console
configFile = "config-file"
)
// AddConfigFileFlag adds flags for ExternalConfFlags
func AddConfigFileFlag(flagSet *flag.FlagSet) {
flagSet.String(configFile, "", "Configuration file in JSON, TOML, YAML, HCL, or Java properties formats (default none). See spf13/viper for precedence.")
}
// TryLoadConfigFile initializes viper with config file specified as flag
func TryLoadConfigFile(v *viper.Viper) error {
if file := v.GetString(configFile); file != "" {
v.SetConfigFile(file)
err := v.ReadInConfig()
if err != nil {
return fmt.Errorf("cannot load config file %s: %w", file, err)
}
}
return nil
}
// ParseJaegerTags parses the Jaeger tags string into a map.
func ParseJaegerTags(jaegerTags string) (map[string]string, error) {
if jaegerTags == "" {
return nil, nil
}
tagPairs := strings.Split(string(jaegerTags), ",")
tags := make(map[string]string)
for _, p := range tagPairs {
kv := strings.SplitN(p, "=", 2)
if len(kv) != 2 {
return nil, fmt.Errorf("invalid Jaeger tag pair %q, expected key=value", p)
}
k, v := strings.TrimSpace(kv[0]), strings.TrimSpace(kv[1])View on GitHub (pinned to 806f444784)
Solutions
- Check the path in the message exists and is readable (ls/permissions).
- Validate the file's YAML/JSON syntax with a linter (yamllint, jq).
- Confirm the extension is supported (.yaml, .yml, .json, .toml).
- In Kubernetes, verify the ConfigMap volume is mounted before startup.
Example fix
// before --config-file=/etc/jaeger/config.yamln # typo, file missing // after --config-file=/etc/jaeger/config.yaml
Defensive patterns
Strategy: validation
Validate before calling
path := v.GetString("config-file")
if path != "" {
if _, err := os.Stat(path); err != nil {
return fmt.Errorf("config file not readable: %w", err)
}
if err := yaml.Unmarshal; /* validate syntax */ ; err != nil {
return err
}
} Try / catch
if err := TryLoadConfigFile(v); err != nil {
var pathErr *fs.PathError
if errors.As(err, &pathErr) { /* fix path/permissions */ }
return fmt.Errorf("startup aborted: %w", err)
} Prevention
- Lint config files (yamllint/jq) in CI before shipping them.
- Use absolute paths and ensure volume mounts precede process start.
- Match file extension to actual syntax (.yaml vs .json).
- Verify permissions for the process user inside the container.
When it happens
Trigger: Passing --config-file pointing to a nonexistent file, a file with an extension Viper cannot infer, unreadable permissions, or a malformed YAML/JSON document that fails Unmarshal.
Common situations: Typo in the mounted config path; ConfigMap not mounted yet at process start; YAML indentation error introduced by hand-editing; renaming the file to .yaml while it contains JSON with wrong syntax.
Related errors
- failed to initialize config: %w
- cannot load config file: %w
- no sampling strategy provider specified, expecting 'adaptive
- only one sampling strategy provider can be specified, 'adapt
- reload interval must be a positive value, or zero to disable
AI-assisted analysis of jaegertracing/jaeger@806f444784 (2026-09-01).
Data as JSON: /api/errors/4efa6b66a54f33a5.
Report an issue: GitHub.