{"record":{"id":"8d1ecde6f82d4cd8","repo":"gofiber/fiber","slug":"value-not-found","errorCode":null,"errorMessage":"value not found","messagePattern":"value not found","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"info","filePath":"extractors/extractors.go","lineNumber":65,"sourceCode":"\n\t// SourceForm indicates the value is extracted from form data.\n\tSourceForm\n\n\t// SourceQuery indicates the value is extracted from URL query parameters.\n\tSourceQuery\n\n\t// SourceParam indicates the value is extracted from URL path parameters.\n\tSourceParam\n\n\t// SourceCookie indicates the value is extracted from cookies.\n\tSourceCookie\n\n\t// SourceCustom indicates the value is extracted using a custom extractor function.\n\tSourceCustom\n)\n\n// ErrNotFound is returned when the requested value is missing or empty.\nvar ErrNotFound = errors.New(\"value not found\")\n\n// ErrChainCycle is returned when a chain extractor recursively invokes itself.\nvar ErrChainCycle = errors.New(\"cyclic extractor chain\")\n\n// Extractor defines a value extraction method with metadata.\ntype Extractor struct {\n\tExtract    func(fiber.Ctx) (string, error)\n\tKey        string      // The parameter/header name used for extraction\n\tAuthScheme string      // The auth scheme used, e.g., \"Bearer\"\n\tChain      []Extractor // For chained extractors, stores all extractors in the chain\n\tSource     Source      // The type of source being extracted from\n}\n\n// Contains reports whether this extractor, or any extractor in its chain, matches pred.\n//\n// If pred is nil, Contains returns false.\nfunc (e Extractor) Contains(pred func(Extractor) bool) bool {\n\tif pred == nil {","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/gofiber/fiber/blob/a105acad6c1e4576a77f01e02973f67e962bb58d/extractors/extractors.go#L47-L83","documentation":"ErrNotFound is the extractors package sentinel (extractors/extractors.go:65) returned by every leaf extractor when the requested value is absent or empty. It is the expected non-fatal signal used by Chain to fall through to the next extractor, and by application code to short-circuit to a 401/404. Note this is a different value from any fiber-root ErrNotFound.","triggerScenarios":"FromAuthHeader when the Authorization header is missing or empty; FromCookie when the cookie is unset; FromParam when the URL parameter is empty or fails url.PathUnescape; FromForm/FromHeader/FromQuery when the named field is absent; FromCustom when the supplied function is nil; Chain when no inner extractor yields a value.","commonSituations":"Building an auth extractor chain (header -> cookie -> query) where some sources are absent in normal traffic; clients that omit a required cookie; routes that share an extractor but not all have the same parameters.","solutions":["Treat ErrNotFound as expected: if errors.Is(err, extractors.ErrNotFound) { return c.SendStatus(fiber.StatusUnauthorized) }.","Use Chain so that a missing primary source falls through to a secondary extractor rather than failing the request.","Distinguish missing-value (ErrNotFound) from a parse failure (a different error) so error responses stay accurate."],"exampleFix":"// before\nval, err := extractor.Extract(c)\nif err != nil {\n    return err\n}\n// after\nval, err := extractor.Extract(c)\nif errors.Is(err, extractors.ErrNotFound) {\n    return c.SendStatus(fiber.StatusUnauthorized)\n}\nif err != nil {\n    return err\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"// isExtractorNotFound reports whether the extractor found no value,\n// which is an expected condition during chain traversal.\nfunc isExtractorNotFound(err error) bool {\n    return errors.Is(err, extractors.ErrNotFound)\n}","tryCatchPattern":"val, err := extractor.Extract(c)\nif err != nil {\n    if isExtractorNotFound(err) {\n        return c.SendStatus(fiber.StatusUnauthorized)\n    }\n    return err\n}","preventionTips":["Use Chain so a missing primary source falls through to a secondary extractor.","Treat ErrNotFound as expected and map it to the right HTTP status (401/404).","Distinguish missing-value (ErrNotFound) from a parse failure so error responses stay accurate."],"tags":["extractors","auth","binding","sentinel","expected"],"backgroundTag":null,"analyzedSha":"a105acad6c1e4576a77f01e02973f67e962bb58d","analyzedAt":"2026-08-11T17:33:26.942Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}