{"record":{"id":"0f1ac8569e508b93","repo":"gofiber/fiber","slug":"binder-invalid-destination-value","errorCode":null,"errorMessage":"binder: invalid destination value","messagePattern":"binder: invalid destination value","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"binder/binder.go","lineNumber":22,"sourceCode":"\t\"errors\"\n\t\"sync\"\n)\n\nconst (\n\tbindingURI        = \"uri\"\n\tbindingForm       = \"form\"\n\tbindingQuery      = \"query\"\n\tbindingHeader     = \"header\"\n\tbindingRespHeader = \"respHeader\"\n\tbindingCookie     = \"cookie\"\n)\n\n// Binder errors\nvar (\n\tErrSuitableContentNotFound = errors.New(\"binder: suitable content not found to parse body\")\n\tErrMapNotConvertible       = errors.New(\"binder: map is not convertible to map[string]string or map[string][]string\")\n\tErrMapNilDestination       = errors.New(\"binder: map destination is nil and cannot be initialized\")\n\tErrInvalidDestinationValue = errors.New(\"binder: invalid destination value\")\n\tErrUnmatchedBrackets       = errors.New(\"unmatched brackets\")\n)\n\nvar errPoolTypeAssertion = errors.New(\"failed to type-assert to T\")\n\nvar HeaderBinderPool = sync.Pool{\n\tNew: func() any {\n\t\treturn &HeaderBinding{}\n\t},\n}\n\nvar RespHeaderBinderPool = sync.Pool{\n\tNew: func() any {\n\t\treturn &RespHeaderBinding{}\n\t},\n}\n\nvar CookieBinderPool = sync.Pool{","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/gofiber/fiber/blob/a105acad6c1e4576a77f01e02973f67e962bb58d/binder/binder.go#L4-L40","documentation":"Returned by parseToMap (binder/mapping.go:131) when target.IsValid() is false — i.e. the reflect.Value passed in is the zero Value. This happens when the destination is a nil interface{} or nil pointer with no concrete type behind it, so reflection cannot even determine a kind to populate.","triggerScenarios":"Calling parseToMap with reflect.ValueOf(nil-interface) or reflect.Value{} directly; passing a nil any as the bind destination through a code path that reaches parseToMap.","commonSituations":"Binding into an uninitialized `var out any` variable; a nil pointer to a map/struct passed where reflect expects a valid value; misuse of the binder package's internal parseToMap without a concrete destination.","solutions":["Ensure the destination is a non-nil pointer to a concrete type before binding: var out MyType; c.Bind().Query(&out).","If the type is dynamic, initialize the interface to a concrete zero value before passing it.","Avoid calling binder.parseToMap directly; use the public Bind.* methods which validate the destination first."],"exampleFix":"// before\nvar out any // nil interface\nerr := parseToMap(reflect.ValueOf(out), data) // ErrInvalidDestinationValue\n\n// after\nout := map[string]string{}\nerr := parseToMap(reflect.ValueOf(out), data)","handlingStrategy":"validation","validationCode":"// Reject nil-interface destinations before binding\nfunc mustBeConcretePointer(out any) error {\n    if out == nil { return errors.New(\"nil destination\") }\n    if reflect.ValueOf(out).Kind() != reflect.Ptr { return errors.New(\"destination must be a pointer\") }\n    return nil\n}","typeGuard":"func isNonNilPointer(v any) bool {\n    return v != nil && reflect.ValueOf(v).Kind() == reflect.Ptr && !reflect.ValueOf(v).IsNil()\n}","tryCatchPattern":"if err := c.Bind().Query(out); err != nil {\n    if errors.Is(err, binder.ErrInvalidDestinationValue) {\n        // initialize a concrete zero value and retry\n    }\n}","preventionTips":["Never pass a nil interface as a bind destination.","Always bind into a concrete local: var out T; c.Bind().Query(&out).","Avoid calling binder internals directly."],"tags":["binding","reflection","fiber"],"backgroundTag":null,"analyzedSha":"a105acad6c1e4576a77f01e02973f67e962bb58d","analyzedAt":"2026-08-11T17:33:26.942Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}