{"id":"1ce9b6c00bda9b47","repo":"gofiber/fiber","slug":"unknown-binding-source-q","errorCode":null,"errorMessage":"unknown binding_source %q","messagePattern":"unknown binding_source %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"bind.go","lineNumber":491,"sourceCode":"\t\t\tfor p := range parts {\n\t\t\t\tsourceName := strings.TrimSpace(p)\n\t\t\t\tif sourceName == \"\" {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tvar source bindSource\n\t\t\t\tswitch sourceName {\n\t\t\t\tcase \"uri\":\n\t\t\t\t\tsource = sourceURI\n\t\t\t\tcase \"body\":\n\t\t\t\t\tsource = sourceBody\n\t\t\t\tcase \"query\":\n\t\t\t\t\tsource = sourceQuery\n\t\t\t\tcase \"header\":\n\t\t\t\t\tsource = sourceHeader\n\t\t\t\tcase \"cookie\":\n\t\t\t\t\tsource = sourceCookie\n\t\t\t\tdefault:\n\t\t\t\t\terr := fmt.Errorf(\"unknown binding_source %q\", sourceName)\n\t\t\t\t\tbindingPrecedenceCache.Store(t, cachedPrecedence{err: err, sources: nil})\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\n\t\t\t\t// check for duplicates\n\t\t\t\tif !slices.Contains(precedence, source) {\n\t\t\t\t\tprecedence = append(precedence, source)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tbindingPrecedenceCache.Store(t, cachedPrecedence{err: nil, sources: precedence})\n\treturn precedence, nil\n}\n\n// All binds values from URI params, the request body, the query string,\n// headers, and cookies into the provided struct in precedence order.\n// Returns *BindError on parse failure (manual mode) or *Error with status 400 (auto-handling mode).","sourceCodeStart":473,"sourceCodeEnd":509,"githubUrl":"https://github.com/gofiber/fiber/blob/9a4c7e57fe0b080a04235d28a4b0d2b4b353d58c/bind.go#L473-L509","documentation":"Returned by getBindingPrecedence (bind.go:491) when a `binding_source` struct tag contains a source name that isn't in the recognized set {uri, body, query, header, cookie}. The parser trims whitespace and switches on the exact token; anything else (typo, case mismatch, unsupported source) is rejected and the error is cached for that struct type so subsequent binds fail fast.","triggerScenarios":"A tag like `binding_source:\"params\"`, `binding_source:\"headers\"` (plural), `binding_source:\"form\"`, or `binding_source:\"URI\"` (uppercase) — any token outside the five allowed lowercase names — on a struct passed to Bind().All().","commonSituations":"Typing a plural or synonyms (headers, params, form, path); using a case the switch doesn't match; attempting to bind a source Fiber doesn't expose (e.g. 'json' — body covers it).","solutions":["Use only the allowed tokens: uri, body, query, header, cookie (lowercase, singular).","For JSON bodies use 'body' (the body binder handles the media type).","Add a unit test that binds a sample request per struct type so typos surface at test time, not in production."],"exampleFix":"// before\ntype Req struct { Q string `binding_source:\"params\"` }\n\n// after\ntype Req struct { Q string `binding_source:\"query\"` }","handlingStrategy":"validation","validationCode":"// Allowed binding_source tokens.\nvar allowedBindingSources = map[string]bool{\n    \"uri\": true, \"body\": true, \"query\": true, \"header\": true, \"cookie\": true,\n}\n\n// In a test, reflect over struct tags and assert each binding_source token is allowed.","typeGuard":null,"tryCatchPattern":"if err := c.Bind().All(&req); err != nil {\n    if strings.Contains(err.Error(), \"unknown binding_source\") {\n        // typo in a binding_source tag — fix the token\n        return fiber.NewError(fiber.StatusBadRequest, \"bad request schema\")\n    }\n    return err\n}","preventionTips":["Use only: uri, body, query, header, cookie (lowercase, singular).","For JSON request bodies, use 'body' (the body binder handles the media type).","Validate request-struct tags in a dedicated unit test."],"tags":["binding","struct-tag","validation","reflection"],"analyzedSha":"9a4c7e57fe0b080a04235d28a4b0d2b4b353d58c","analyzedAt":"2026-08-04T21:44:03.395Z","schemaVersion":2}