{"record":{"id":"8b4d9f46f344b486","repo":"caddyserver/caddy","slug":"encoding-stek-gob-v","errorCode":null,"errorMessage":"encoding STEK gob: %v","messagePattern":"encoding STEK gob: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"modules/caddytls/distributedstek/distributedstek.go","lineNumber":137,"sourceCode":"func (s *Provider) loadSTEK() (distributedSTEK, error) {\n\tvar sg distributedSTEK\n\tgobBytes, err := s.storage.Load(s.ctx, stekFileName)\n\tif err != nil {\n\t\treturn sg, err // don't wrap, in case error is certmagic.ErrNotExist\n\t}\n\tdec := gob.NewDecoder(bytes.NewReader(gobBytes))\n\terr = dec.Decode(&sg)\n\tif err != nil {\n\t\treturn sg, fmt.Errorf(\"STEK gob corrupted: %v\", err)\n\t}\n\treturn sg, nil\n}\n\nfunc (s *Provider) storeSTEK(dstek distributedSTEK) error {\n\tvar buf bytes.Buffer\n\terr := gob.NewEncoder(&buf).Encode(dstek)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"encoding STEK gob: %v\", err)\n\t}\n\terr = s.storage.Store(s.ctx, stekFileName, buf.Bytes())\n\tif err != nil {\n\t\treturn fmt.Errorf(\"storing STEK gob: %v\", err)\n\t}\n\treturn nil\n}\n\n// getSTEK locks and loads the current STEK from storage. If none\n// currently exists, a new STEK is created and persisted. If the\n// current STEK is outdated (NextRotation time is in the past),\n// then it is rotated and persisted. The resulting STEK is returned.\nfunc (s *Provider) getSTEK() (distributedSTEK, error) {\n\terr := s.storage.Lock(s.ctx, stekLockName)\n\tif err != nil {\n\t\treturn distributedSTEK{}, fmt.Errorf(\"failed to acquire storage lock: %v\", err)\n\t}\n","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/caddyserver/caddy/blob/50e54ee279aa1e504fe218ca49ab6ae16c100410/modules/caddytls/distributedstek/distributedstek.go#L119-L155","documentation":"storeSTEK gob-encodes the distributedSTEK value before writing it to storage; encode failures are wrapped as 'encoding STEK gob'. Gob encode of this struct essentially cannot fail in practice unless in-memory state is corrupted or contains unsupported types introduced by a code change.","triggerScenarios":"Memory corruption or a bug (in Caddy or a plugin modifying STEK state); theoretically an unexported/unsupported field type change in distributedSTEK.","commonSituations":"Near-never seen in the field; if it appears, suspect a faulty build or a patched fork of Caddy/caddytls.","solutions":["Treat as a bug: capture logs and the Caddy/xcaddy build list (caddy version, plugins) and report it","Rebuild with stock Caddy if running a fork with modified STEK structures","Restart the instance to reset in-memory STEK state; if persistent, delete the stored stek object as a last resort"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"// If orchestrating Caddy programmatically, a transient in-memory encode failure\n// is cleared by re-provisioning (reload). Persistent recurrence = bug: collect 'caddy version'\n// and plugin list and report upstream.","preventionTips":["Run stock or minimally-patched builds; STEK gob encode failing is a code-level anomaly","Keep xcaddy plugin set small and versioned","After any fork changes to caddytls structs, run the distributedstek tests: go test ./modules/caddytls/distributedstek/..."],"tags":["tls","stek","gob","internal"],"backgroundTag":null,"analyzedSha":"50e54ee279aa1e504fe218ca49ab6ae16c100410","analyzedAt":"2026-08-15T09:20:21.641Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}