{"id":"6436dfd17e1d5562","repo":"gofiber/fiber","slug":"fiber-shared-state-s-s-is-not-configured","errorCode":null,"errorMessage":"fiber: shared state %s %s is not configured","messagePattern":"fiber: shared state (.+?) (.+?) is not configured","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shared_state.go","lineNumber":405,"sourceCode":"\t\tdefer func() {\n\t\t\trecovered = recover()\n\t\t}()\n\n\t\terr = decoder(data, out)\n\t}()\n\n\tif recovered != nil {\n\t\treturn sharedStateCodecPanicError(\"decode\", format, recovered)\n\t}\n\tif err != nil {\n\t\treturn fmt.Errorf(\"fiber: failed to decode shared state %s value: %w\", format, err)\n\t}\n\n\treturn nil\n}\n\nfunc sharedStateCodecNotConfiguredError(format, direction string) error {\n\treturn fmt.Errorf(\"fiber: shared state %s %s is not configured\", format, direction)\n}\n\nfunc sharedStateCodecPanicError(operation, format string, recovered any) error {\n\tif err, ok := recovered.(error); ok {\n\t\treturn fmt.Errorf(\"fiber: failed to %s shared state %s value: %w\", operation, format, err)\n\t}\n\n\treturn fmt.Errorf(\"fiber: failed to %s shared state %s value: %v\", operation, format, recovered)\n}\n\nfunc (s *SharedState) storageKey(key string) (string, bool) {\n\tif key == \"\" {\n\t\treturn \"\", false\n\t}\n\n\treturn s.prefix + hex.EncodeToString(utils.UnsafeBytes(key)), true\n}\n","sourceCodeStart":387,"sourceCodeEnd":423,"githubUrl":"https://github.com/gofiber/fiber/blob/9a4c7e57fe0b080a04235d28a4b0d2b4b353d58c/shared_state.go#L387-L423","documentation":"Returned by sharedStateCodecNotConfiguredError (shared_state.go:405) when a shared-state codec operation is attempted for a format whose encoder/decoder was never configured. Fiber ships defaults only for JSON and XML; MsgPack and CBOR require explicit cfg.MsgPackEncoder/Decoder, cfg.CBOREncoder/Decoder. The message names both the format and the direction (encoder/decoder).","triggerScenarios":"Calling app.SharedState().SetMsgPack/GetMsgPack without setting Config.MsgPackEncoder and Config.MsgPackDecoder; calling SetCBOR/GetCBOR without Config.CBOREncoder/Decoder. encodeSharedStateValue/decodeSharedStateValue see a nil codec function and return this error.","commonSituations":"Using SharedState MsgPack/CBOR APIs for the first time without wiring codecs; removing the codec config during a refactor; assuming defaults exist for all formats like JSON.","solutions":["Provide both encoder and decoder for the format in fiber.Config: MsgPackEncoder/MsgPackDecoder (or CBOR variants).","Use a supported codec implementation, e.g. github.com/vmihailenco/msgpack/v5 or github.com/fxamacker/cbor.","If you only need JSON/XML, switch to SetJSON/SetXML which have working defaults.","Register codecs once at app construction; do not rely on per-call configuration."],"exampleFix":"// before: using msgpack without codecs\napp := fiber.New(fiber.Config{SharedStorage: store})\n_ = app.SharedState().SetMsgPack(ctx, \"k\", v, ttl)\n\n// after: wire msgpack codecs in Config\nimport \"github.com/vmihailenco/msgpack/v5\"\napp := fiber.New(fiber.Config{\n    SharedStorage:   store,\n    MsgPackEncoder:  msgpack.Marshal,\n    MsgPackDecoder:  msgpack.Unmarshal,\n})","handlingStrategy":"validation","validationCode":"if cfg.MsgPackEncoder == nil || cfg.MsgPackDecoder == nil {\n    // either wire codecs or do not use SetMsgPack/GetMsgPack\n    cfg.MsgPackEncoder = msgpack.Marshal\n    cfg.MsgPackDecoder = msgpack.Unmarshal\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember only JSON and XML have default codecs; MsgPack/CBOR need config.","Set both encoder and decoder for any format you use.","Use SetJSON/SetXML if you do not want to wire extra codecs."],"tags":["shared-state","config","codecs","msgpack","cbor","misconfiguration"],"analyzedSha":"9a4c7e57fe0b080a04235d28a4b0d2b4b353d58c","analyzedAt":"2026-08-04T21:44:03.395Z","schemaVersion":2}