{"record":{"id":"a560109d6ecdfc58","repo":"gofiber/fiber","slug":"favicon-file-size-exceeds-max-bytes-d","errorCode":null,"errorMessage":"favicon: file size exceeds max bytes %d","messagePattern":"favicon: file size exceeds max bytes (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"middleware/favicon/favicon.go","lineNumber":110,"sourceCode":"\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":92,"sourceCodeEnd":114,"githubUrl":"https://github.com/gofiber/fiber/blob/a105acad6c1e4576a77f01e02973f67e962bb58d/middleware/favicon/favicon.go#L92-L114","documentation":"Returned by favicon.readLimited when the favicon file exceeds Config.MaxBytes. The function reads MaxBytes+1 bytes; if it reads more than MaxBytes, the file is too large and (like error 165) New() panics with this message at middleware construction. Default MaxBytes is small to keep favicons lightweight.","triggerScenarios":"favicon.New configured with a File whose size is greater than Config.MaxBytes. Triggers at startup during the one-shot read in New(), causing the process to panic before serving traffic.","commonSituations":"Dropping a high-resolution .ico/.png as favicon.ico, leaving the default small MaxBytes, or pointing File at a multi-resolution .ico that contains 32/64/128px variants and exceeds the cap.","solutions":["Use a smaller favicon — strip oversized icon variants to fit MaxBytes.","Raise Config.MaxBytes to a value that comfortably covers the file (e.g. 1<<20).","If the file is intentionally large, prefer serving it via a static handler instead of the favicon middleware.","Check the file size at deploy time: `stat -c%s cfg.File`."],"exampleFix":"// before\napp.Use(favicon.New())\n// after\napp.Use(favicon.New(favicon.Config{\n    File:     \"./assets/favicon.ico\",\n    MaxBytes: 1 << 20, // 1 MiB\n}))","handlingStrategy":"validation","validationCode":"if fi, err := os.Stat(cfg.File); err == nil && fi.Size() > int64(cfg.MaxBytes) { log.Fatalf(\"favicon too large: %d > %d\", fi.Size(), cfg.MaxBytes) }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check the file size at deploy time.","Raise Config.MaxBytes if you intend to serve larger icons.","Use a minimal single-resolution favicon to stay well under the default cap."],"tags":["favicon","config","startup-panic","file-size"],"backgroundTag":null,"analyzedSha":"a105acad6c1e4576a77f01e02973f67e962bb58d","analyzedAt":"2026-08-11T17:33:26.942Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}