{"record":{"id":"d496156a0dfe3430","repo":"JuliusBrussee/caveman","slug":"redact-payload-exceeds-redaction-size-limit","errorCode":null,"errorMessage":"redact: payload exceeds redaction size limit","messagePattern":"redact: payload exceeds redaction size limit","errorType":"exception","errorClass":"ErrBodyTooLarge","httpStatus":null,"severity":"error","filePath":"shared/platform/redact/payload.go","lineNumber":68,"sourceCode":"// than being silently ignored, because ignoring a rule an operator configured\n// is exactly how unredacted data leaks.\nconst (\n\tRuleTypeRegex    = \"regex\"\n\tRuleTypeJSONPath = \"json_path\"\n\tRuleTypeHeader   = \"header\"\n\tRuleTypeBuiltin  = \"builtin\"\n)\n\n// Origin values distinguish the built-in floor from operator-supplied rules in\n// the report.\nconst (\n\tOriginBuiltin = \"builtin\"\n\tOriginOrg     = \"org\"\n)\n\nvar (\n\t// ErrBodyTooLarge means the body exceeded MaxPayloadBytes.\n\tErrBodyTooLarge = errors.New(\"redact: payload exceeds redaction size limit\")\n\t// ErrInvalidRule means a rule could not be compiled or was structurally\n\t// unusable (empty name/pattern, or a pattern that matches the empty\n\t// string and would therefore rewrite the entire body).\n\tErrInvalidRule = errors.New(\"redact: invalid redaction rule\")\n\t// ErrRuleUnsupported means the rule's type is not implementable against an\n\t// opaque body by this pass.\n\tErrRuleUnsupported = errors.New(\"redact: unsupported redaction rule type\")\n)\n\n// Rule is one enabled row of the redaction_rules table, minus the columns that\n// are the caller's business. Field names and JSON tags are pinned to that\n// table's columns so the two cannot drift.\n//\n// Deliberately absent:\n//   - id / organization_id / project_id — tenancy is the caller's concern.\n//   - enabled — filtering disabled rows is the caller's concern; a rule that\n//     reaches Payload is a rule that runs.\n//","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/shared/platform/redact/payload.go#L50-L86","documentation":"Payload refuses bodies larger than MaxPayloadBytes, returning ErrBodyTooLarge (this message) wrapped with the actual size and the limit. Redaction operates on the full opaque body in memory, so oversized payloads are rejected instead of being partially redacted or exhausting memory.","triggerScenarios":"Calling Payload(body, rules) where len(body) > MaxPayloadBytes — e.g. uploading multi-megabyte JSON/log bodies through a redaction middleware.","commonSituations":"Clients POSTing large exports or log bundles to an endpoint protected by the redact middleware; a limit configured for small API payloads suddenly receiving file-like uploads; limit lowered in a new release making previously-fine payloads too big.","solutions":["Check len(body) against redact.MaxPayloadBytes before calling Payload and reject/stream the request earlier","Split or truncate oversized payloads upstream (chunk the upload) so each piece fits the limit","Raise MaxPayloadBytes deliberately if the workload legitimately needs larger bodies, accounting for memory","Return a 413 Payload Too Large to the client with the documented limit"],"exampleFix":"// before\nredacted, report, err := redact.Payload(body, rules) // body is 10MB, limit exceeded\n// after\nif len(body) > redact.MaxPayloadBytes {\n    return http.StatusRequestEntityTooLarge\n}\nredacted, report, err := redact.Payload(body, rules)","handlingStrategy":"validation","validationCode":"if len(body) > redact.MaxPayloadBytes {\n    return nil, fmt.Errorf(\"body %d bytes exceeds redaction limit %d\", len(body), redact.MaxPayloadBytes)\n}","typeGuard":null,"tryCatchPattern":"redacted, report, err := redact.Payload(body, rules)\nif err != nil {\n    if errors.Is(err, redact.ErrBodyTooLarge) {\n        return http.StatusRequestEntityTooLarge\n    }\n    return err\n}","preventionTips":["Enforce a request size limit (http.MaxBytesReader) below MaxPayloadBytes at the edge","Check len(body) before invoking Payload in hot paths","Keep MaxPayloadBytes and edge limits in sync when either changes","Return 413 with the limit value so clients can adapt"],"tags":["redaction","payload","limit","validation"],"backgroundTag":"payload-too-large","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}