gofiber/fiber · info
value not found
Error message
value not found
What it means
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.
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.
Example fix
// before
val, err := extractor.Extract(c)
if err != nil {
return err
}
// after
val, err := extractor.Extract(c)
if errors.Is(err, extractors.ErrNotFound) {
return c.SendStatus(fiber.StatusUnauthorized)
}
if err != nil {
return err
} Defensive patterns
Strategy: try-catch
Type guard
// isExtractorNotFound reports whether the extractor found no value,
// which is an expected condition during chain traversal.
func isExtractorNotFound(err error) bool {
return errors.Is(err, extractors.ErrNotFound)
} Try / catch
val, err := extractor.Extract(c)
if err != nil {
if isExtractorNotFound(err) {
return c.SendStatus(fiber.StatusUnauthorized)
}
return err
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- binder: custom binder not found, please be sure to enter…
- binder: invalid destination value
- binder: map destination is nil and cannot be initialized
- binder: map is not convertible to map[string]string or…
- binder: msgpack is not configured, please check docs…
AI-assisted analysis of gofiber/fiber@a105acad6c (2026-08-11).
Data as JSON: /api/errors/8d1ecde6f82d4cd8.
Report an issue: GitHub.
Appendix: source
Thrown at extractors/extractors.go:65
// SourceForm indicates the value is extracted from form data.
SourceForm
// SourceQuery indicates the value is extracted from URL query parameters.
SourceQuery
// SourceParam indicates the value is extracted from URL path parameters.
SourceParam
// SourceCookie indicates the value is extracted from cookies.
SourceCookie
// SourceCustom indicates the value is extracted using a custom extractor function.
SourceCustom
)
// ErrNotFound is returned when the requested value is missing or empty.
var ErrNotFound = errors.New("value not found")
// ErrChainCycle is returned when a chain extractor recursively invokes itself.
var ErrChainCycle = errors.New("cyclic extractor chain")
// Extractor defines a value extraction method with metadata.
type Extractor struct {
Extract func(fiber.Ctx) (string, error)
Key string // The parameter/header name used for extraction
AuthScheme string // The auth scheme used, e.g., "Bearer"
Chain []Extractor // For chained extractors, stores all extractors in the chain
Source Source // The type of source being extracted from
}
// Contains reports whether this extractor, or any extractor in its chain, matches pred.
//
// If pred is nil, Contains returns false.
func (e Extractor) Contains(pred func(Extractor) bool) bool {
if pred == nil {View on GitHub (pinned to a105acad6c)