{"record":{"id":"27891e1152a5153e","repo":"caddyserver/caddy","slug":"error-loading-private-key-v-and-cleaning-up-par","errorCode":null,"errorMessage":"error loading private key (%v) and cleaning up parent storage key %s: %v","messagePattern":"error loading private key \\((.+?)\\) and cleaning up parent storage key (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/caddytls/ech.go","lineNumber":546,"sourceCode":"// non-nil privKeyBin and configBin values before using.\nfunc loadECHConfig(ctx caddy.Context, configID string) (echConfig, error) {\n\tstorage := ctx.Storage()\n\tlogger := ctx.Logger()\n\n\tcfgIDKey := path.Join(echConfigsKey, configID)\n\tkeyKey := path.Join(cfgIDKey, \"key.bin\")\n\tconfigKey := path.Join(cfgIDKey, \"config.bin\")\n\tmetaKey := path.Join(cfgIDKey, \"meta.json\")\n\n\t// if loading anything fails, might as well delete this folder and free up\n\t// the config ID; spec is designed to rotate configs frequently anyway\n\t// (I consider it a more serious error if we can't clean up the folder,\n\t// since leaving stray storage keys is confusing)\n\tprivKeyBytes, err := storage.Load(ctx, keyKey)\n\tif err != nil {\n\t\tdelErr := storage.Delete(ctx, cfgIDKey)\n\t\tif delErr != nil {\n\t\t\treturn echConfig{}, fmt.Errorf(\"error loading private key (%v) and cleaning up parent storage key %s: %v\", err, cfgIDKey, delErr)\n\t\t}\n\t\tlogger.Warn(\"could not load ECH private key; deleting its config folder\",\n\t\t\tzap.String(\"config_id\", configID),\n\t\t\tzap.Error(err))\n\t\treturn echConfig{}, nil\n\t}\n\techConfigBytes, err := storage.Load(ctx, configKey)\n\tif err != nil {\n\t\tdelErr := storage.Delete(ctx, cfgIDKey)\n\t\tif delErr != nil {\n\t\t\treturn echConfig{}, fmt.Errorf(\"error loading ECH config (%v) and cleaning up parent storage key %s: %v\", err, cfgIDKey, delErr)\n\t\t}\n\t\tlogger.Warn(\"could not load ECH config; deleting its config folder\",\n\t\t\tzap.String(\"config_id\", configID),\n\t\t\tzap.Error(err))\n\t\treturn echConfig{}, nil\n\t}\n\tvar cfg echConfig","sourceCodeStart":528,"sourceCodeEnd":564,"githubUrl":"https://github.com/caddyserver/caddy/blob/50e54ee279aa1e504fe218ca49ab6ae16c100410/modules/caddytls/ech.go#L528-L564","documentation":"Error \"error loading private key (%v) and cleaning up parent storage key %s: %v\" thrown in caddyserver/caddy.","triggerScenarios":"Thrown at modules/caddytls/ech.go:546 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect both wrapped errors: the private key failed to load, and cleanup of its storage key also failed. Check storage health and key data."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"50e54ee279aa1e504fe218ca49ab6ae16c100410","analyzedAt":"2026-08-15T09:20:21.641Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}