{"record":{"id":"20b06f5afbed34ae","repo":"jaegertracing/jaeger","slug":"failed-to-initialize-config-w-20b06f","errorCode":null,"errorMessage":"failed to initialize config: %w","messagePattern":"failed to initialize config: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/es-rollover/app/actions.go","lineNumber":69,"sourceCode":"type Action interface {\n\tDo() error\n}\n\n// ActionExecuteOptions are the options passed to the execute action function\ntype ActionExecuteOptions struct {\n\tArgs   []string\n\tViper  *viper.Viper\n\tLogger *zap.Logger\n}\n\n// ActionCreatorFunction type is the function type in charge of create the action to be executed\ntype ActionCreatorFunction func(*esclient.Client, Config) Action\n\n// ExecuteAction execute the action returned by the createAction function\nfunc ExecuteAction(opts ActionExecuteOptions, createAction ActionCreatorFunction) error {\n\tcfg := Config{}\n\tif err := cfg.InitFromViper(opts.Viper); err != nil {\n\t\treturn fmt.Errorf(\"failed to initialize config: %w\", err)\n\t}\n\n\tesClient, err := newESClient(context.Background(), opts.Args[0], &cfg, opts.Logger)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create Elasticsearch client: %w\", err)\n\t}\n\taction := createAction(esClient, cfg)\n\treturn action.Do()\n}\n","sourceCodeStart":51,"sourceCodeEnd":79,"githubUrl":"https://github.com/jaegertracing/jaeger/blob/806f4447841ecdb60519f408b004a599d515f437/cmd/es-rollover/app/actions.go#L51-L79","documentation":"ExecuteAction in es-rollover first initializes the rollover Config from Viper; if cfg.InitFromViper returns an error (invalid flag values, bad env binding, failed parsing), the error is wrapped with this message and returned. It means the rollover configuration itself could not be built before any ES call was attempted.","triggerScenarios":"Calling ExecuteAction with a Viper instance holding an invalid value for a rollover config field (e.g. non-numeric unit count, malformed duration, bad bool) so cfg.InitFromViper fails.","commonSituations":"Wrong CLI flag values in a cronjob/K8s manifest; environment variable of the wrong type shadowing a flag; typo'd flag name leaving an invalid default; config file loaded with an incompatible key type.","solutions":["Inspect the wrapped cause for the exact field that failed to parse.","Print/validate the rollover flags (ES_URL, index prefix, units, etc.) passed to the command.","Fix the offending flag/env/config-file value and re-run.","Check for stray environment variables overriding flags via viper AutomaticEnv."],"exampleFix":"// before\nROLLOVER_INDEX_DAYS=every-day ./es-rollover init\n// after — numeric/typed values only\nROLLOVER_INDEX_DAYS=30 ./es-rollover init","handlingStrategy":"validation","validationCode":"cfg := app.Config{}\nif err := cfg.InitFromViper(v); err != nil {\n    return fmt.Errorf(\"invalid rollover flags: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := ExecuteAction(opts, createAction); err != nil {\n    var cfgErr *ConfigError\n    if errors.As(err, &cfgErr) { /* fix flag values */ }\n    return err\n}","preventionTips":["Keep flag values typed correctly in manifests (numbers, bools, durations).","Audit environment variables that viper AutomaticEnv may pick up.","Test rollover commands with the same flags in CI before production."],"tags":["config","viper","cli"],"backgroundTag":"config-initialization-failed","analyzedSha":"806f4447841ecdb60519f408b004a599d515f437","analyzedAt":"2026-09-01T02:39:22.140Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}