{"record":{"id":"8cf59604eeb30be6","repo":"caddyserver/caddy","slug":"precompressor-already-added-s","errorCode":null,"errorMessage":"precompressor already added: %s","messagePattern":"precompressor already added: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/caddyhttp/fileserver/staticfiles.go","lineNumber":240,"sourceCode":"\tmods, err := ctx.LoadModule(fsrv, \"PrecompressedRaw\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"loading encoder modules: %v\", err)\n\t}\n\tfor modName, modIface := range mods.(map[string]any) {\n\t\tp, ok := modIface.(encode.Precompressed)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"module %s is not precompressor\", modName)\n\t\t}\n\t\tae := p.AcceptEncoding()\n\t\tif ae == \"\" {\n\t\t\treturn fmt.Errorf(\"precompressor does not specify an Accept-Encoding value\")\n\t\t}\n\t\tsuffix := p.Suffix()\n\t\tif suffix == \"\" {\n\t\t\treturn fmt.Errorf(\"precompressor does not specify a Suffix value\")\n\t\t}\n\t\tif _, ok := fsrv.precompressors[ae]; ok {\n\t\t\treturn fmt.Errorf(\"precompressor already added: %s\", ae)\n\t\t}\n\t\tif fsrv.precompressors == nil {\n\t\t\tfsrv.precompressors = make(map[string]encode.Precompressed)\n\t\t}\n\t\tfsrv.precompressors[ae] = p\n\t}\n\n\tif fsrv.Browse != nil {\n\t\t// check sort options\n\t\tfor idx, sortOption := range fsrv.Browse.SortOptions {\n\t\t\tswitch idx {\n\t\t\tcase 0:\n\t\t\t\tif sortOption != sortByName && sortOption != sortByNameDirFirst && sortOption != sortBySize && sortOption != sortByTime {\n\t\t\t\t\treturn fmt.Errorf(\"the first option must be one of the following: %s, %s, %s, %s, but got %s\", sortByName, sortByNameDirFirst, sortBySize, sortByTime, sortOption)\n\t\t\t\t}\n\t\t\tcase 1:\n\t\t\t\tif sortOption != sortOrderAsc && sortOption != sortOrderDesc {\n\t\t\t\t\treturn fmt.Errorf(\"the second option must be one of the following: %s, %s, but got %s\", sortOrderAsc, sortOrderDesc, sortOption)","sourceCodeStart":222,"sourceCodeEnd":258,"githubUrl":"https://github.com/caddyserver/caddy/blob/50e54ee279aa1e504fe218ca49ab6ae16c100410/modules/caddyhttp/fileserver/staticfiles.go#L222-L258","documentation":"Returned in FileServer.Provision when two configured precompressor modules report the same Accept-Encoding value. The precompressors map is keyed by Accept-Encoding, so a duplicate would silently overwrite one module's sidecar suffix with another's; Caddy rejects the config instead.","triggerScenarios":"Listing the same encoding twice (e.g. `precompressed gzip gzip` in Caddyfile, or two keys mapping to modules with AcceptEncoding() == \"gzip\" in JSON), or two different plugins that both claim the same encoding token.","commonSituations":"Copy-paste duplication in the precompressed list; installing two third-party plugins that both implement gzip/zstd; JSON config hand-edited to add an encoding already provided by a built-in module.","solutions":["Deduplicate the precompressed list so each Accept-Encoding appears once.","If two plugins claim the same encoding, keep only one in the build (xcaddy build flags) or in the config.","Run `caddy validate` after editing the precompressed config to catch this before restart."],"exampleFix":"# before\nprecompressed zstd gzip gzip br\n# after\nprecompressed zstd gzip br","handlingStrategy":"validation","validationCode":"# Lint your Caddyfile before deploy: no duplicate tokens in precompressed\nline=$(grep -E '^\\s*precompressed' Caddyfile | sed 's/^\\s*precompressed//')\nseen=\"\"; for tok in $line; do\n  case \" $seen \" in *\" $tok \"*) echo \"duplicate precompressor: $tok\"; exit 1;; esac\n  seen=\"$seen $tok\"\ndone","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep the precompressed list on one line and deduplicated.","When installing multiple encoding plugins, confirm their AcceptEncoding values don't collide.","`caddy validate` catches this before a reload breaks the server."],"tags":["caddy","fileserver","precompressed","duplicate-config","provisioning"],"backgroundTag":null,"analyzedSha":"50e54ee279aa1e504fe218ca49ab6ae16c100410","analyzedAt":"2026-08-15T09:20:21.641Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}