{"record":{"id":"de0fe81d4aeca67a","repo":"caddyserver/caddy","slug":"invalid-action-type","errorCode":null,"errorMessage":"invalid action type","messagePattern":"invalid action type","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/logging/filters.go","lineNumber":306,"sourceCode":"\nconst (\n\t// Replace value(s).\n\treplaceAction filterAction = \"replace\"\n\n\t// Hash value(s).\n\thashAction filterAction = \"hash\"\n\n\t// Delete.\n\tdeleteAction filterAction = \"delete\"\n)\n\nfunc (a filterAction) IsValid() error {\n\tswitch a {\n\tcase replaceAction, deleteAction, hashAction:\n\t\treturn nil\n\t}\n\n\treturn errors.New(\"invalid action type\")\n}\n\ntype queryFilterAction struct {\n\t// `replace` to replace the value(s) associated with the parameter(s), `hash` to replace them with the 4 initial bytes of the SHA-256 of their content or `delete` to remove them entirely.\n\tType filterAction `json:\"type\"`\n\n\t// The name of the query parameter.\n\tParameter string `json:\"parameter\"`\n\n\t// The value to use as replacement if the action is `replace`.\n\tValue string `json:\"value,omitempty\"`\n}\n\n// QueryFilter is a Caddy log field filter that filters\n// query parameters from a URL.\n//\n// This filter updates the logged URL string to remove, replace or hash\n// query parameters containing sensitive data. For instance, it can be","sourceCodeStart":288,"sourceCodeEnd":324,"githubUrl":"https://github.com/caddyserver/caddy/blob/50e54ee279aa1e504fe218ca49ab6ae16c100410/modules/logging/filters.go#L288-L324","documentation":"filterAction.IsValid() in the logging module rejects any query-filter action type that is not one of the three literals 'replace', 'hash', or 'delete'. It is returned by QueryFilter.Validate() during config provisioning, so it fails at load time, never at request time. The value comes straight from the 'type' field of an action object in the query filter config.","triggerScenarios":"JSON config with log encoder filter {\"filter\": \"query\", \"actions\": [{\"type\": \"redact\", \"parameter\": \"token\"}]}; typo like \"delelte\" or \"Hash\" (case-sensitive); passing an action object without a recognized type value.","commonSituations":"Hand-writing the logs JSON config instead of using the Caddyfile syntax; porting a redaction config from another tool whose action names differ (e.g. 'remove', 'mask'); uppercase or localized variants of the action names.","solutions":["Change the action type to exactly one of: replace, hash, or delete (lowercase)","If using the Caddyfile, use the documented forms: replace <param> <value>, hash <param>, delete <param>","Validate the logging config with caddy validate --config <file> --adapter <adapter> before deploying","If 'replace' is chosen, also include the required 'value' field"],"exampleFix":"// before\n{\n  \"logs\": {\n    \"log0\": {\n      \"encoder\": {\n        \"format\": \"filter\",\n        \"wrap\": {\"format\": \"json\"},\n        \"fields\": {\n          \"uri\": {\n            \"filter\": \"query\",\n            \"actions\": [{\"type\": \"redact\", \"parameter\": \"token\"}]\n          }\n        }\n      }\n    }\n  }\n}\n\n// after\n\"actions\": [{\"type\": \"delete\", \"parameter\": \"token\"}]","handlingStrategy":"validation","validationCode":"var validActions = map[string]bool{\"replace\": true, \"hash\": true, \"delete\": true}\n\nfunc validateQueryFilter(cfg map[string]any) error {\n\tfor _, f := range cfg[\"actions\"].([]any) {\n\t\ta := f.(map[string]any)\n\t\tif !validActions[a[\"type\"].(string)] {\n\t\t\treturn fmt.Errorf(\"invalid action type %q: use replace, hash, or delete\", a[\"type\"])\n\t\t}\n\t}\n\treturn nil\n}","typeGuard":"type FilterAction string\n\nfunc (a FilterAction) Valid() bool {\n\tswitch a {\n\tcase \"replace\", \"hash\", \"delete\":\n\t\treturn true\n\t}\n\treturn false\n}","tryCatchPattern":null,"preventionTips":["Use the Caddyfile query filter syntax (replace/hash/delete) instead of raw JSON where possible","Lint logging config in CI with caddy validate","Remember action names are lowercase and case-sensitive"],"tags":["logging","configuration","validation","caddyfile"],"backgroundTag":null,"analyzedSha":"50e54ee279aa1e504fe218ca49ab6ae16c100410","analyzedAt":"2026-08-15T09:20:21.641Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}