gofiber/fiber · error
binder: must explicitly set up CBOR, please check docs…
Error message
binder: must explicitly set up CBOR, please check docs: https://docs.gofiber.io/next/guide/advance-format#cbor
What it means
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).
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.
Example fix
// before
app := fiber.New()
// handler calls c.Bind().CBOR() -> ErrUnimplementedCBOR
// after
import "github.com/fxamacker/cbor/v2"
app := fiber.New(fiber.Config{
CBOREncoder: cbor.Marshal,
CBORDecoder: cbor.Unmarshal,
}) Defensive patterns
Strategy: validation
Validate before calling
// Assert CBOR is configured at startup
func assertCBORConfigured(app *fiber.App) error {
if app.Config().CBORDecoder == nil || reflect.ValueOf(app.Config().CBORDecoder).Pointer() == reflect.ValueOf(binder.UnimplementedCborUnmarshal).Pointer() {
return errors.New("CBOR not configured; set Config.CBORDecoder/CBOREncoder")
}
return nil
} Try / catch
if err := c.Bind().CBOR(&out); err != nil {
if errors.Is(err, binder.ErrUnimplementedCBOR) {
return c.Status(fiber.StatusNotImplemented).SendString("cbor not configured")
}
return err
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- binder: msgpack is not configured, please check docs…
- binder: invalid destination value
- binder: map destination is nil and cannot be initialized
- binder: map is not convertible to map[string]string or…
- binder: suitable content not found to parse body
AI-assisted analysis of gofiber/fiber@a105acad6c (2026-08-11).
Data as JSON: /api/errors/e680f2c6c2d8a6e1.
Report an issue: GitHub.
Appendix: source
Thrown at binder/cbor.go:31
// Name returns the binding name.
func (*CBORBinding) Name() string {
return "cbor"
}
// Bind parses the request body as CBOR and returns the result.
func (b *CBORBinding) Bind(body []byte, out any) error {
return b.CBORDecoder(body, out)
}
// Reset resets the CBORBinding binder.
func (b *CBORBinding) Reset() {
b.CBORDecoder = nil
}
// ErrUnimplementedCBOR signals that CBOR support must be explicitly configured
// before it can be used.
var ErrUnimplementedCBOR = errors.New("binder: must explicitly set up CBOR, please check docs: https://docs.gofiber.io/next/guide/advance-format#cbor")
// UnimplementedCborMarshal returns an error to signal that a CBOR marshaler
// must be configured before CBOR support can be used.
func UnimplementedCborMarshal(_ any) ([]byte, error) {
return nil, ErrUnimplementedCBOR
}
// UnimplementedCborUnmarshal returns an error to signal that a CBOR unmarshaler
// must be configured before CBOR support can be used.
func UnimplementedCborUnmarshal(_ []byte, _ any) error {
return ErrUnimplementedCBOR
}
View on GitHub (pinned to a105acad6c)