{"record":{"id":"6ea82fb3e28c5efc","repo":"crowdsecurity/crowdsec","slug":"invalid-body-size-exceeded-action-q-must-be-s","errorCode":null,"errorMessage":"invalid body_size_exceeded_action %q (must be %s, %s, or %s)","messagePattern":"invalid body_size_exceeded_action %q \\(must be (.+?), (.+?), or (.+?)\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/appsec/appsec.go","lineNumber":1803,"sourceCode":"\t}\n\n\tstate.Fingerprint.LogAccepted(w.Logger, log.InfoLevel, request.ClientIP, request.RemoteAddrNormalized, \"granted allowlist challenge cookie inline (submit phase)\")\n\n\treturn nil\n}\n\n// SetBodySizeExceededAction sets what happens when the body exceeds the maximum size.\n// Valid values: \"drop\" (block request), \"partial\" (inspect up to max size), \"allow\" (skip body inspection).\n// Intended for use in on_load hooks.\nfunc (w *AppsecRuntimeConfig) SetBodySizeExceededAction(action string) error {\n\tswitch action {\n\tcase BodySizeActionDrop, BodySizeActionPartial, BodySizeActionAllow:\n\t\tw.Logger.Debugf(\"setting body size exceeded action to %q\", action)\n\t\tw.BodySettings.Action = action\n\n\t\treturn nil\n\tdefault:\n\t\treturn fmt.Errorf(\"invalid body_size_exceeded_action %q (must be %s, %s, or %s)\", action, BodySizeActionDrop, BodySizeActionPartial, BodySizeActionAllow)\n\t}\n}\n\n// DisableBodyInspection prevents Coraza from processing the request body for the current request.\n// Intended for use in pre_eval hooks.\nfunc (w *AppsecRuntimeConfig) DisableBodyInspection(state *AppsecRequestState) error {\n\tstate.DisableBodyInspection = true\n\tw.Logger.Debugf(\"body inspection disabled for this request\")\n\n\treturn nil\n}\n\ntype BodyResponse struct {\n\tAction          string              `json:\"action\"`\n\tHTTPStatus      int                 `json:\"http_status\"`\n\tUserBodyContent string              `json:\"user_body_content,omitempty\"`\n\tUserCookies     []string            `json:\"user_cookies,omitempty\"`\n\tUserHeaders     map[string][]string `json:\"user_headers,omitempty\"`","sourceCodeStart":1785,"sourceCodeEnd":1821,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/appsec/appsec.go#L1785-L1821","documentation":"The appsec-config's body_size_exceeded_action accepts only three enum values: drop, partial, allow. The SetBodySizeExceededAction-style setter rejects any other string with this error. It is a config validation error caught at appsec runtime build time.","triggerScenarios":"Setting `body_size_exceeded_action:` in an appsec-config to a value like `block`, `reject`, or `DROP` (case-sensitive) instead of exactly drop/partial/allow.","commonSituations":"User guesses the action name by analogy with other WAF configs; uppercase value; documentation from an older version listing different actions; YAML unquoted value altered by parsing.","solutions":["Set the value to exactly one of: drop, partial, allow (lowercase)","Remove the key entirely to use the default action","Check the version's documentation — if only drop/partial existed in your version, upgrade before using allow","Quote the YAML value to avoid parser mangling"],"exampleFix":"// before (appsec-config.yaml)\nbody_size_exceeded_action: block\n// after\nbody_size_exceeded_action: drop","handlingStrategy":"validation","validationCode":"valid := map[string]bool{\"drop\": true, \"partial\": true, \"allow\": true}\nif v := cfg.BodySizeExceededAction; v != \"\" && !valid[strings.ToLower(v)] {\n    return fmt.Errorf(\"body_size_exceeded_action must be drop, partial or allow, got %q\", v)\n}","typeGuard":null,"tryCatchPattern":"if err := buildAppsecRuntime(cfg); err != nil {\n    if strings.Contains(err.Error(), \"body_size_exceeded_action\") {\n        log.Fatalf(\"fix appsec-config enum value: %v\", err)\n    }\n    return err\n}","preventionTips":["Copy enum values from official example configs, don't retype","Remember values are lowercase and case-sensitive","Keep a schema/yamllint check on appsec-config files in CI"],"tags":["appsec","config","enum"],"backgroundTag":"invalid-enum-value","analyzedSha":"909b5157986a2b2c2163300fdaef5ed01289f7d2","analyzedAt":"2026-09-06T12:27:26.012Z","contentChangedAt":"2026-09-06T12:27:26.012Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}