{"record":{"id":"a0037edd0464cd2d","repo":"hibiken/asynq","slug":"initial-call-to-getconfigs-failed-w","errorCode":null,"errorMessage":"initial call to GetConfigs failed: %w","messagePattern":"initial call to GetConfigs failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"periodic_task_manager.go","lineNumber":171,"sourceCode":"\tmgr.s.Shutdown()\n}\n\n// Run starts the manager and blocks until an os signal to exit the program is received.\n// Once it receives a signal, it gracefully shuts down the manager.\nfunc (mgr *PeriodicTaskManager) Run() error {\n\tif err := mgr.Start(); err != nil {\n\t\treturn err\n\t}\n\tmgr.s.waitForSignals()\n\tmgr.Shutdown()\n\tmgr.s.logger.Debugf(\"PeriodicTaskManager exiting\")\n\treturn nil\n}\n\nfunc (mgr *PeriodicTaskManager) initialSync() error {\n\tconfigs, err := mgr.p.GetConfigs()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"initial call to GetConfigs failed: %w\", err)\n\t}\n\tfor _, c := range configs {\n\t\tif err := validatePeriodicTaskConfig(c); err != nil {\n\t\t\treturn fmt.Errorf(\"initial call to GetConfigs contained an invalid config: %w\", err)\n\t\t}\n\t}\n\tmgr.add(configs)\n\treturn nil\n}\n\nfunc (mgr *PeriodicTaskManager) add(configs []*PeriodicTaskConfig) {\n\tfor _, c := range configs {\n\t\tentryID, err := mgr.s.Register(c.Cronspec, c.Task, c.Opts...)\n\t\tif err != nil {\n\t\t\tmgr.s.logger.Errorf(\"Failed to register periodic task: cronspec=%q task=%q err=%v\",\n\t\t\t\tc.Cronspec, c.Task.Type(), err)\n\t\t\tcontinue\n\t\t}","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/hibiken/asynq/blob/d135f1439bee74e989b7f9b41ecd542cc87f024a/periodic_task_manager.go#L153-L189","documentation":"PeriodicTaskManager.initialSync fails when the very first call to the provider's GetConfigs returns an error. The manager cannot build its scheduler without the initial config list, so startup is aborted and the error is wrapped by Start.","triggerScenarios":"mgr.p.GetConfigs() returns a non-nil error during Start: provider's backing store (DB, Redis, file, remote API) is unreachable, credentials fail, or the provider itself returns an error by design.","commonSituations":"Config database down or migrations not applied at boot; network policy blocking the config service in k8s; provider returning errors for empty/locked tables.","solutions":["Diagnose the wrapped provider error and fix the root cause (connectivity, credentials, schema)","Make the provider resilient: retry transient failures inside GetConfigs before surfacing","Optionally delay Start until the config source is known to be available (health check first)"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// probe before starting\nif _, err := provider.GetConfigs(); err != nil {\n    return fmt.Errorf(\"config source unavailable: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := mgr.Start(); err != nil {\n    if isTransient(err) {\n        time.Sleep(backoff)\n        return mgr.Start()\n    }\n    return err\n}","preventionTips":["Add retry with backoff inside GetConfigs for transient network/store errors","Ensure the config store is up before the worker starts (startup ordering/health checks)","Return descriptive errors from the provider so root causes are visible"],"tags":["asynq","config-provider","startup","network"],"backgroundTag":"api-request-failed","analyzedSha":"d135f1439bee74e989b7f9b41ecd542cc87f024a","analyzedAt":"2026-09-07T19:02:34.660Z","contentChangedAt":"2026-09-07T19:02:34.660Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}