{"record":{"id":"4efa6b66a54f33a5","repo":"jaegertracing/jaeger","slug":"cannot-load-config-file-s-w","errorCode":null,"errorMessage":"cannot load config file %s: %w","messagePattern":"cannot load config file (.+?): %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/internal/flags/flags.go","lineNumber":35,"sourceCode":"\nconst (\n\tlogLevel    = \"log-level\"\n\tlogEncoding = \"log-encoding\" // json or console\n\tconfigFile  = \"config-file\"\n)\n\n// AddConfigFileFlag adds flags for ExternalConfFlags\nfunc AddConfigFileFlag(flagSet *flag.FlagSet) {\n\tflagSet.String(configFile, \"\", \"Configuration file in JSON, TOML, YAML, HCL, or Java properties formats (default none). See spf13/viper for precedence.\")\n}\n\n// TryLoadConfigFile initializes viper with config file specified as flag\nfunc TryLoadConfigFile(v *viper.Viper) error {\n\tif file := v.GetString(configFile); file != \"\" {\n\t\tv.SetConfigFile(file)\n\t\terr := v.ReadInConfig()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"cannot load config file %s: %w\", file, err)\n\t\t}\n\t}\n\treturn nil\n}\n\n// ParseJaegerTags parses the Jaeger tags string into a map.\nfunc ParseJaegerTags(jaegerTags string) (map[string]string, error) {\n\tif jaegerTags == \"\" {\n\t\treturn nil, nil\n\t}\n\ttagPairs := strings.Split(string(jaegerTags), \",\")\n\ttags := make(map[string]string)\n\tfor _, p := range tagPairs {\n\t\tkv := strings.SplitN(p, \"=\", 2)\n\t\tif len(kv) != 2 {\n\t\t\treturn nil, fmt.Errorf(\"invalid Jaeger tag pair %q, expected key=value\", p)\n\t\t}\n\t\tk, v := strings.TrimSpace(kv[0]), strings.TrimSpace(kv[1])","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/jaegertracing/jaeger/blob/806f4447841ecdb60519f408b004a599d515f437/cmd/internal/flags/flags.go#L17-L53","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\n--config-file=/etc/jaeger/config.yamln  # typo, file missing\n// after\n--config-file=/etc/jaeger/config.yaml","handlingStrategy":"validation","validationCode":"path := v.GetString(\"config-file\")\nif path != \"\" {\n    if _, err := os.Stat(path); err != nil {\n        return fmt.Errorf(\"config file not readable: %w\", err)\n    }\n    if err := yaml.Unmarshal; /* validate syntax */ ; err != nil {\n        return err\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := TryLoadConfigFile(v); err != nil {\n    var pathErr *fs.PathError\n    if errors.As(err, &pathErr) { /* fix path/permissions */ }\n    return fmt.Errorf(\"startup aborted: %w\", err)\n}","preventionTips":["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."],"tags":["config","viper","file-io"],"backgroundTag":"config-file-not-loadable","analyzedSha":"806f4447841ecdb60519f408b004a599d515f437","analyzedAt":"2026-09-01T02:39:22.140Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}