{"record":{"id":"e680f2c6c2d8a6e1","repo":"gofiber/fiber","slug":"binder-must-explicitly-set-up-cbor-please-check","errorCode":null,"errorMessage":"binder: must explicitly set up CBOR, please check docs: https://docs.gofiber.io/next/guide/advance-format#cbor","messagePattern":"binder: must explicitly set up CBOR, please check docs: https://docs\\.gofiber\\.io/next/guide/advance-format#cbor","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"binder/cbor.go","lineNumber":31,"sourceCode":"\n// Name returns the binding name.\nfunc (*CBORBinding) Name() string {\n\treturn \"cbor\"\n}\n\n// Bind parses the request body as CBOR and returns the result.\nfunc (b *CBORBinding) Bind(body []byte, out any) error {\n\treturn b.CBORDecoder(body, out)\n}\n\n// Reset resets the CBORBinding binder.\nfunc (b *CBORBinding) Reset() {\n\tb.CBORDecoder = nil\n}\n\n// ErrUnimplementedCBOR signals that CBOR support must be explicitly configured\n// before it can be used.\nvar ErrUnimplementedCBOR = errors.New(\"binder: must explicitly set up CBOR, please check docs: https://docs.gofiber.io/next/guide/advance-format#cbor\")\n\n// UnimplementedCborMarshal returns an error to signal that a CBOR marshaler\n// must be configured before CBOR support can be used.\nfunc UnimplementedCborMarshal(_ any) ([]byte, error) {\n\treturn nil, ErrUnimplementedCBOR\n}\n\n// UnimplementedCborUnmarshal returns an error to signal that a CBOR unmarshaler\n// must be configured before CBOR support can be used.\nfunc UnimplementedCborUnmarshal(_ []byte, _ any) error {\n\treturn ErrUnimplementedCBOR\n}\n","sourceCodeStart":13,"sourceCodeEnd":44,"githubUrl":"https://github.com/gofiber/fiber/blob/a105acad6c1e4576a77f01e02973f67e962bb58d/binder/cbor.go#L13-L44","documentation":"Returned by binder.UnimplementedCborMarshal and binder.UnimplementedCborUnmarshal (binder/cbor.go:31, :36, :42), which are the DEFAULT values of App.Config.CBOREncoder and App.Config.CBORDecoder. Fiber ships without a CBOR implementation; CBOR is opt-in, so any CBOR bind/send path fires this sentinel until you wire a real codec (e.g. github.com/fxamacker/cbor).","triggerScenarios":"A request arrives with Content-Type: application/cbor and you call c.Bind().CBOR() without having set Config.CBORDecoder; or you call c.CBOR().Send() without Config.CBOREncoder; or the client hits the bind.Body() CBOR branch (bind.go:421-422) with the default still in place.","commonSituations":"New Fiber app that has not configured advanced formats; a client suddenly sending application/cbor; enabling CBOR in one handler but forgetting the global Config; upgrading Fiber and finding CBOR is no longer bundled by default.","solutions":["Import a CBOR library (github.com/fxamacker/cbor/v2) and set app.Config().CBORDecoder = cbor.Unmarshal and app.Config().CBOREncoder = cbor.Marshal before registering routes.","If CBOR is not needed, reject application/cbor requests at a middleware boundary so they never reach Bind.Body().","For the HTTP client, call client.SetCBORMarshal / SetCBORUnmarshal with the same codec.","Verify with a unit test that app.Config().CBORDecoder != binder.UnimplementedCborUnmarshal after setup."],"exampleFix":"// before\napp := fiber.New()\n// handler calls c.Bind().CBOR() -> ErrUnimplementedCBOR\n\n// after\nimport \"github.com/fxamacker/cbor/v2\"\napp := fiber.New(fiber.Config{\n    CBOREncoder: cbor.Marshal,\n    CBORDecoder: cbor.Unmarshal,\n})","handlingStrategy":"validation","validationCode":"// Assert CBOR is configured at startup\nfunc assertCBORConfigured(app *fiber.App) error {\n    if app.Config().CBORDecoder == nil || reflect.ValueOf(app.Config().CBORDecoder).Pointer() == reflect.ValueOf(binder.UnimplementedCborUnmarshal).Pointer() {\n        return errors.New(\"CBOR not configured; set Config.CBORDecoder/CBOREncoder\")\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"if err := c.Bind().CBOR(&out); err != nil {\n    if errors.Is(err, binder.ErrUnimplementedCBOR) {\n        return c.Status(fiber.StatusNotImplemented).SendString(\"cbor not configured\")\n    }\n    return err\n}","preventionTips":["Configure CBOREncoder/CBORDecoder in fiber.Config at New() time.","Add a startup test that the codec is not the Unimplemented default.","Reject application/cbor at the edge until CBOR is configured."],"tags":["cbor","binding","configuration","fiber"],"backgroundTag":null,"analyzedSha":"a105acad6c1e4576a77f01e02973f67e962bb58d","analyzedAt":"2026-08-11T17:33:26.942Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}