{"record":{"id":"87a1ae22cab8acd5","repo":"gofiber/fiber","slug":"favicon-read-limited-w","errorCode":null,"errorMessage":"favicon: read limited: %w","messagePattern":"favicon: read limited: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"middleware/favicon/favicon.go","lineNumber":107,"sourceCode":"\t\t}\n\n\t\t// Serve cached favicon\n\t\tif iconLen > 0 {\n\t\t\tc.Set(fiber.HeaderContentLength, iconLenHeader)\n\t\t\tc.Set(fiber.HeaderContentType, hType)\n\t\t\tc.Set(fiber.HeaderCacheControl, cfg.CacheControl)\n\t\t\treturn c.Status(fiber.StatusOK).Send(iconData)\n\t\t}\n\n\t\treturn c.SendStatus(fiber.StatusNoContent)\n\t}\n}\n\nfunc readLimited(reader io.Reader, maxBytes int64) ([]byte, error) {\n\tlimit := maxBytes + 1\n\tdata, err := io.ReadAll(io.LimitReader(reader, limit))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"favicon: read limited: %w\", err)\n\t}\n\tif int64(len(data)) > maxBytes {\n\t\treturn nil, fmt.Errorf(\"favicon: file size exceeds max bytes %d\", maxBytes)\n\t}\n\treturn data, nil\n}\n","sourceCodeStart":89,"sourceCodeEnd":114,"githubUrl":"https://github.com/gofiber/fiber/blob/a105acad6c1e4576a77f01e02973f67e962bb58d/middleware/favicon/favicon.go#L89-L114","documentation":"Returned by favicon.readLimited when io.ReadAll fails while reading the favicon file (capped at MaxBytes+1 via LimitReader). The wrapped %w is the underlying reader error — typically an I/O failure on the open file or embedded FS. Note: New() panics on this error at middleware construction time, so it surfaces as a startup panic, not a per-request error.","triggerScenarios":"Constructing favicon.New with a Config.File whose content cannot be read — disk read error, file truncated mid-read, broken embed.FS, NFS hiccup, or a reader that errors after partial data. readLimited is called once during New(), so the panic happens at app startup.","commonSituations":"Bad file path that opens but reads incompletely, a corrupt embedded asset, a network-mounted filesystem with intermittent errors, or a container where the favicon file is a broken symlink/mount at read time.","solutions":["Check the file is readable end-to-end: `cat cfg.File > /dev/null` on the host/container.","If using embed.FS, rebuild the binary so the embedded bytes are intact.","Validate the file at startup and fail with a clear message instead of panicking.","Ensure the path/permissions are correct in the deployment environment."],"exampleFix":"// before\napp.Use(favicon.New(favicon.Config{File: \"/srv/favicon.ico\"}))\n// after\nf, err := os.ReadFile(\"/srv/favicon.ico\")\nif err != nil { log.Fatal(err) }\napp.Use(favicon.New(favicon.Config{Data: f}))","handlingStrategy":"validation","validationCode":"if _, err := os.ReadFile(cfg.File); err != nil { log.Fatal(err) }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Read and validate the favicon file at startup before calling favicon.New.","Prefer favicon.Config.Data with bytes loaded by the application.","For embed.FS, rebuild the binary after asset changes."],"tags":["favicon","io","startup-panic","filesystem"],"backgroundTag":null,"analyzedSha":"a105acad6c1e4576a77f01e02973f67e962bb58d","analyzedAt":"2026-08-11T17:33:26.942Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}