{"record":{"id":"5842e3505a23877b","repo":"jaegertracing/jaeger","slug":"cannot-load-config-file-w","errorCode":null,"errorMessage":"cannot load config file: %w","messagePattern":"cannot load config file: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/internal/flags/service.go","lineNumber":65,"sourceCode":"\treturn &Service{\n\t\tAdmin:          NewAdminServer(ports.PortToHostPort(adminPort)),\n\t\tsignalsChannel: signalsChannel,\n\t}\n}\n\n// AddFlags registers CLI flags.\nfunc (s *Service) AddFlags(flagSet *flag.FlagSet) {\n\tAddConfigFileFlag(flagSet)\n\tAddLoggingFlags(flagSet)\n\tmetricsbuilder.AddFlags(flagSet)\n\ts.Admin.AddFlags(flagSet)\n\tfeaturegate.GlobalRegistry().RegisterFlags(flagSet)\n}\n\n// Start bootstraps the service and starts the admin server.\nfunc (s *Service) Start(v *viper.Viper) error {\n\tif err := TryLoadConfigFile(v); err != nil {\n\t\treturn fmt.Errorf(\"cannot load config file: %w\", err)\n\t}\n\n\tsFlags := new(SharedFlags).InitFromViper(v)\n\tnewProdConfig := zap.NewProductionConfig()\n\tnewProdConfig.Sampling = nil\n\tlogger, err := sFlags.NewLogger(newProdConfig)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"cannot create logger: %w\", err)\n\t}\n\ts.Logger = logger\n\tgrpclog.SetLoggerV2(zapgrpc.NewLogger(\n\t\tlogger.WithOptions(\n\t\t\tzap.AddCallerSkip(5), // ensure the actual caller:lineNo is shown\n\t\t),\n\t))\n\n\tmetricsBuilder := new(metricsbuilder.Builder).InitFromViper(v)\n\tmetricsFactory, err := metricsBuilder.CreateMetricsFactory(\"\")","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/jaegertracing/jaeger/blob/806f4447841ecdb60519f408b004a599d515f437/cmd/internal/flags/service.go#L47-L83","documentation":"Service.Start is the bootstrap for Jaeger services; its first step loads the config file via TryLoadConfigFile, and any error there is re-wrapped as \"cannot load config file\". This is the outer wrapper users see when --config-file is bad; the inner cause names the actual file and Viper error.","triggerScenarios":"Starting any Jaeger service (all-in-one, collector, query) with --config-file set to a missing, unreadable, or syntactically invalid file, so TryLoadConfigFile returns an error and Start aborts.","commonSituations":"Wrong path in a K8s args list; ConfigMap key renamed; YAML syntax error; file mounted with restrictive permissions; docker-compose volume not mounted.","solutions":["Look at the chained cause for the exact file and Viper error.","Fix the path/permissions or correct the YAML/JSON syntax.","Validate the config file parses before deploying (yamllint/jq).","If no config file is intended, remove the --config-file flag entirely."],"exampleFix":"// before\nargs: [\"--config-file=/etc/jaeger/config.yaml\"]  # ConfigMap not mounted\n// after: add the volume mount\nvolumeMounts: [{ name: jaeger-config, mountPath: /etc/jaeger }]","handlingStrategy":"try-catch","validationCode":"if cf := v.GetString(\"config-file\"); cf != \"\" {\n    if fi, err := os.Stat(cf); err != nil || fi.IsDir() {\n        return fmt.Errorf(\"bad --config-file %s\", cf)\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := svc.Start(v); err != nil {\n    if strings.Contains(err.Error(), \"cannot load config file\") {\n        // check --config-file path and syntax per the wrapped cause\n    }\n    return err\n}","preventionTips":["Pin the config file path and validate it exists in entrypoint scripts.","Ship config syntax validation as a CI step.","Ensure ConfigMap mounts are ready before the container starts.","Omit --config-file when no external config is used."],"tags":["config","startup","viper"],"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"}