{"record":{"id":"cfcc13b6c9f52b3d","repo":"gofiber/fiber","slug":"failed-to-save-response-w","errorCode":null,"errorMessage":"failed to save response: %w","messagePattern":"failed to save response: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"middleware/idempotency/idempotency.go","lineNumber":180,"sourceCode":"\t\t\t\t// Filter\n\t\t\t\tres.Headers = make(map[string][]string)\n\t\t\t\tfor h, vals := range headers {\n\t\t\t\t\tif shouldKeepHeader(h) {\n\t\t\t\t\t\tres.Headers[h] = vals\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Marshal response\n\t\tbs, err := res.MarshalMsg(nil)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to marshal response: %w\", err)\n\t\t}\n\n\t\t// Store response\n\t\tif err := cfg.Storage.SetWithContext(c, key, bs, cfg.Lifetime); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to save response: %w\", err)\n\t\t}\n\n\t\t_ = c.Locals(localsKeyWasPutToCache, true)\n\n\t\treturn nil\n\t}\n}\n","sourceCodeStart":162,"sourceCodeEnd":188,"githubUrl":"https://github.com/gofiber/fiber/blob/a105acad6c1e4576a77f01e02973f67e962bb58d/middleware/idempotency/idempotency.go#L162-L188","documentation":"Returned when cfg.Storage.SetWithContext fails while persisting the freshly computed response under the idempotency key for cfg.Lifetime. The wrapped %w is the storage backend's error. The handler executed, but the response could not be cached, so subsequent retries with the same key will re-execute the handler (no idempotency guarantee until a later write succeeds).","triggerScenarios":"After the request handler completes and the response is marshaled, Storage.SetWithContext(key, bs, Lifetime) returns a non-nil error — Redis/DB write failure, connection broken, value too large for the backend, or context cancellation.","commonSituations":"Storage backend full (Redis maxmemory eviction disabled), network partition during write, marshaled payload exceeds backend size limits, client disconnect cancelling the request context, or storage credentials revoked mid-flight.","solutions":["Check storage health, capacity, and connectivity.","If the response is large, raise backend limits or exclude big payloads from caching via Next.","Decide whether to surface the failure to the client (current behavior) or log-and-continue.","Monitor SetWithContext error rate to detect capacity/availability issues."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Size storage for the largest cached response.","Monitor SetWithContext error rates.","Decide whether a write failure should fail the request or be logged."],"tags":["idempotency","storage","redis","write-failure"],"backgroundTag":null,"analyzedSha":"a105acad6c1e4576a77f01e02973f67e962bb58d","analyzedAt":"2026-08-11T17:33:26.942Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}