{"record":{"id":"70a9641c5bb2fe5b","repo":"gofiber/fiber","slug":"cache-failed-to-get-raw-key-q-from-storage-w","errorCode":null,"errorMessage":"cache: failed to get raw key %q from storage: %w","messagePattern":"cache: failed to get raw key %q from storage: %w","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"middleware/cache/manager.go","lineNumber":145,"sourceCode":"\t}\n\n\tif value := m.memory.Get(key); value != nil {\n\t\tit, ok := value.(*item)\n\t\tif !ok {\n\t\t\treturn nil, fmt.Errorf(\"cache: unexpected entry type %T for key %q\", value, m.logKey(key))\n\t\t}\n\t\treturn it, nil\n\t}\n\n\treturn nil, errCacheMiss\n}\n\n// get raw data from storage or memory\nfunc (m *manager) getRaw(ctx context.Context, key string) ([]byte, error) {\n\tif m.storage != nil {\n\t\traw, err := m.storage.GetWithContext(ctx, key)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"cache: failed to get raw key %q from storage: %w\", m.logKey(key), err)\n\t\t}\n\t\tif raw == nil {\n\t\t\treturn nil, errCacheMiss\n\t\t}\n\t\treturn raw, nil\n\t}\n\n\tif value := m.memory.Get(key); value != nil {\n\t\traw, ok := value.([]byte)\n\t\tif !ok {\n\t\t\treturn nil, fmt.Errorf(\"cache: unexpected raw entry type %T for key %q\", value, m.logKey(key))\n\t\t}\n\t\treturn raw, nil\n\t}\n\n\treturn nil, errCacheMiss\n}\n","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/gofiber/fiber/blob/a105acad6c1e4576a77f01e02973f67e962bb58d/middleware/cache/manager.go#L127-L163","documentation":"Returned by manager.getRaw (the raw-body fetch path) when an external Storage's GetWithContext errors. Parallel to error 141 but for the separated raw response body (key+\"_body\") stored alongside the msgp metadata entry when cfg.Storage is configured.","triggerScenarios":"Cache lookup on an external-Storage deployment where the body was stored separately; Storage.GetWithContext fails for the *_body key: backend down, timeout, connection error, context cancellation.","commonSituations":"Same as 141 — Redis/storage outage, pool exhaustion, client disconnect propagating context cancellation, TLS/auth issues, failover. Surfaces specifically on the second leg of a two-key cache lookup.","solutions":["Examine the wrapped error to classify (network vs context-cancellation vs protocol).","Verify Storage health, connection pool, and timeouts.","If intermittent, treat as cache miss and serve from the handler rather than failing the request.","Ensure the raw-body key namespace is not evicted independently of the metadata key (consistent TTLs)."],"exampleFix":"// before\nraw, err := m.storage.GetWithContext(ctx, key)\nif err != nil {\n    return nil, fmt.Errorf(\"cache: failed to get raw key %q from storage: %w\", m.logKey(key), err)\n}\n\n// after: degrade to miss on transient storage errors\nraw, err := m.storage.GetWithContext(ctx, key)\nif err != nil {\n    if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) {\n        return nil, err\n    }\n    return nil, errCacheMiss\n}","handlingStrategy":"retry","validationCode":"// Verify the raw-body namespace is writable/readable before serving.\nfunc probeRawBody(ctx context.Context, s fiber.Storage) error {\n    k := \"__probe_body\"\n    if err := s.SetWithContext(ctx, k, []byte(\"x\"), time.Second); err != nil {\n        return err\n    }\n    if _, err := s.GetWithContext(ctx, k); err != nil {\n        return err\n    }\n    return s.DeleteWithContext(ctx, k)\n}","typeGuard":null,"tryCatchPattern":"raw, err := m.storage.GetWithContext(ctx, key)\nif err != nil {\n    if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) {\n        return nil, err\n    }\n    log.Warn(\"raw-body fetch failed, treating as miss:\", err)\n    return nil, errCacheMiss\n}","preventionTips":["Use the same TTL on raw-body and metadata keys so they expire together.","Keep the raw-body key namespace consistent with the metadata namespace.","Monitor Storage health to catch transient outages early."],"tags":["cache","storage","network","raw-body","go","fiber"],"backgroundTag":null,"analyzedSha":"a105acad6c1e4576a77f01e02973f67e962bb58d","analyzedAt":"2026-08-11T17:33:26.942Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}