{"record":{"id":"71a610ffe01db13b","repo":"caddyserver/caddy","slug":"invalid-precompressed-flag-v","errorCode":null,"errorMessage":"invalid precompressed flag: %v","messagePattern":"invalid precompressed flag: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/caddyhttp/fileserver/command.go","lineNumber":101,"sourceCode":"\t})\n}\n\nfunc cmdFileServer(fs caddycmd.Flags) (int, error) {\n\tcaddy.TrapSignals()\n\n\tdomain := fs.String(\"domain\")\n\troot := fs.String(\"root\")\n\tlisten := fs.String(\"listen\")\n\tbrowse := fs.Bool(\"browse\")\n\ttemplates := fs.Bool(\"templates\")\n\taccessLog := fs.Bool(\"access-log\")\n\tfileLimit := fs.Int(\"file-limit\")\n\tdebug := fs.Bool(\"debug\")\n\trevealSymlinks := fs.Bool(\"reveal-symlinks\")\n\tcompress := !fs.Bool(\"no-compress\")\n\tprecompressed, err := fs.GetStringSlice(\"precompressed\")\n\tif err != nil {\n\t\treturn caddy.ExitCodeFailedStartup, fmt.Errorf(\"invalid precompressed flag: %v\", err)\n\t}\n\tvar handlers []json.RawMessage\n\n\tif compress {\n\t\tzstd, err := caddy.GetModule(\"http.encoders.zstd\")\n\t\tif err != nil {\n\t\t\treturn caddy.ExitCodeFailedStartup, err\n\t\t}\n\n\t\tgzip, err := caddy.GetModule(\"http.encoders.gzip\")\n\t\tif err != nil {\n\t\t\treturn caddy.ExitCodeFailedStartup, err\n\t\t}\n\n\t\thandlers = append(handlers, caddyconfig.JSONModuleObject(encode.Encode{\n\t\t\tEncodingsRaw: caddy.ModuleMap{\n\t\t\t\t\"zstd\": caddyconfig.JSON(zstd.New(), nil),\n\t\t\t\t\"gzip\": caddyconfig.JSON(gzip.New(), nil),","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/caddyserver/caddy/blob/50e54ee279aa1e504fe218ca49ab6ae16c100410/modules/caddyhttp/fileserver/command.go#L83-L119","documentation":"`caddy file-server` CLI startup error: the --precompressed flag could not be parsed as a string slice. The wrapped error comes from the flag parser (pflag) when the value is malformed.","triggerScenarios":"Passing --precompressed with an invalid list form, e.g. --precompressed= (empty with bad splitting) or quoting oddities that make fs.GetStringSlice(\"precompressed\") fail.","commonSituations":"Shell scripts with unquoted or malformed comma lists: --precompressed gzip,,zstd; wrapper scripts mangling arguments.","solutions":["Pass a clean comma-separated list: caddy file-server --precompressed gzip zstd (repeatable) or --precompressed=gzip,zstd","Check the shell script for empty tokens or stray quotes","Validate arguments before invoking the command in automation"],"exampleFix":"# before\ncaddy file-server --precompressed \"gzip,,zstd\"\n# after\ncaddy file-server --precompressed gzip,zstd","handlingStrategy":"validation","validationCode":"# normalize flags before invoking\nprecompressed=$(echo \"$PRECOMPRESSED\" | tr ',' '\\n' | sed '/^$/d' | paste -sd, -)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep comma lists free of empty tokens","Wrap the CLI in a script that validates flags"],"tags":["caddy","cli","fileserver","flags"],"backgroundTag":null,"analyzedSha":"50e54ee279aa1e504fe218ca49ab6ae16c100410","analyzedAt":"2026-08-15T09:20:21.641Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}