{"record":{"id":"1ce9b6c00bda9b47","repo":"gofiber/fiber","slug":"unknown-binding-source-q","errorCode":null,"errorMessage":"unknown binding_source %q","messagePattern":"unknown binding_source %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"bind.go","lineNumber":484,"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":466,"sourceCodeEnd":502,"githubUrl":"https://github.com/gofiber/fiber/blob/a105acad6c1e4576a77f01e02973f67e962bb58d/bind.go#L466-L502","documentation":"The `binding_source` tag accepts only: uri, body, query, header, cookie. Any other token (e.g., form, path, params) makes getBindingPrecedence return fmt.Errorf(\"unknown binding_source %q\", sourceName). Like [76], the failure is cached in bindingPrecedenceCache.","triggerScenarios":"Annotating a field with a binding_source value outside the allowed set, e.g., `binding_source:\"form\"` or `binding_source:\"path\"`.","commonSituations":"Misspelling a source name; assuming a source exists that doesn't (form, path); using values from an older/different library.","solutions":["Use only the supported tokens: uri, body, query, header, cookie.","For form bodies, use `body` with the appropriate Content-Type.","Double-check spelling against the switch statement in getBindingPrecedence."],"exampleFix":"// before\ntype Req struct {\n    Q string `binding_source:\"form\"`\n}\n\n// after\ntype Req struct {\n    Q string `query:\"q\"`        // or use `binding_source:\"query\"` if custom precedence is required\n}","handlingStrategy":"validation","validationCode":"allowed := map[string]bool{\"uri\": true, \"body\": true, \"query\": true, \"header\": true, \"cookie\": true}\nfor _, src := range strings.Split(tag, \",\") {\n    if !allowed[strings.TrimSpace(src)] { return fmt.Errorf(\"bad binding_source %q\", src) }\n}","typeGuard":"func isValidBindingSource(tag string) bool {\n    allowed := map[string]bool{\"uri\": true, \"body\": true, \"query\": true, \"header\": true, \"cookie\": true}\n    for _, s := range strings.Split(tag, \",\") {\n        if !allowed[strings.TrimSpace(s)] { return false }\n    }\n    return true\n}","tryCatchPattern":null,"preventionTips":["Use only the five supported tokens.","For form bodies, use `body` with the right Content-Type.","Add a CI lint that scans binding_source tags against the allowed set."],"tags":["bind","struct-tags","validation","config"],"backgroundTag":null,"analyzedSha":"a105acad6c1e4576a77f01e02973f67e962bb58d","analyzedAt":"2026-08-11T17:33:26.942Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}