JuliusBrussee/caveman · error · ErrRuleUnsupported
redact: unsupported redaction rule type
Error message
redact: unsupported redaction rule type
What it means
ErrRuleUnsupported is returned by compileOrgRules when a rule's Type is not implementable against an opaque body by this redaction pass: jsonpath and header rule types are rejected explicitly, as is any unrecognized type. Only regex rules are currently executable, so the library fails loudly rather than silently skipping a rule the org believes is active.
Solutions
- Convert the rule to type 'regex' with an equivalent regular expression
- Remove or disable the jsonpath/header rule rows until this pass supports them
- Add a constraint/enum check on redaction_rules.type so unsupported types are rejected at insert time
- Match the default/unknown branch: verify the exact stored type string for typos
Example fix
// before
redact.Rule{Name: "auth", Type: redact.RuleTypeHeader, Pattern: "Authorization"} // unsupported
// after
redact.Rule{Name: "auth", Type: redact.RuleTypeRegex, Pattern: "(?i)authorization\":\s*\"[^\"]+\""} Defensive patterns
Strategy: validation
Validate before calling
switch r.Type {
case redact.RuleTypeRegex:
// ok
default:
return fmt.Errorf("rule %q type %q unsupported; use regex", r.Name, r.Type)
} Type guard
func isSupportedRuleType(t redact.RuleType) bool { return t == redact.RuleTypeRegex } Try / catch
redacted, report, err := redact.Payload(body, rules)
if err != nil && errors.Is(err, redact.ErrRuleUnsupported) {
log.Errorf("rule type not implementable on opaque body: %v", err)
return err
} Prevention
- Restrict redaction_rules.type to 'regex' via a DB enum/constraint
- Migrate jsonpath/header rules to equivalent regex rules before loading
- When adding a new RuleType, implement it in compileOrgRules in the same change
- Log and alert on ErrRuleUnsupported so dormant unsupported rules are surfaced early
When it happens
Trigger: Persisting a redaction_rules row with type='jsonpath', type='header', or a typo'd/unknown type value and then calling Payload with those rules loaded from the table.
Common situations: Rules authored for a different redaction engine (HTTP-header scrubbers, JSON-tree rewriters) being loaded into this pass; a new RuleType enum value added to the table before the engine implements it; data-entry typos like 'regeex'.
Related errors
- redact: invalid redaction rule
- redact: payload exceeds redaction size limit
- : bytes (limit )
- : empty name
- : (rule )
AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20).
Data as JSON: /api/errors/3f516a39a11d6f67.
Report an issue: GitHub.
Appendix: source
Thrown at shared/platform/redact/payload.go:75
)
// Origin values distinguish the built-in floor from operator-supplied rules in
// the report.
const (
OriginBuiltin = "builtin"
OriginOrg = "org"
)
var (
// ErrBodyTooLarge means the body exceeded MaxPayloadBytes.
ErrBodyTooLarge = errors.New("redact: payload exceeds redaction size limit")
// ErrInvalidRule means a rule could not be compiled or was structurally
// unusable (empty name/pattern, or a pattern that matches the empty
// string and would therefore rewrite the entire body).
ErrInvalidRule = errors.New("redact: invalid redaction rule")
// ErrRuleUnsupported means the rule's type is not implementable against an
// opaque body by this pass.
ErrRuleUnsupported = errors.New("redact: unsupported redaction rule type")
)
// Rule is one enabled row of the redaction_rules table, minus the columns that
// are the caller's business. Field names and JSON tags are pinned to that
// table's columns so the two cannot drift.
//
// Deliberately absent:
// - id / organization_id / project_id — tenancy is the caller's concern.
// - enabled — filtering disabled rows is the caller's concern; a rule that
// reaches Payload is a rule that runs.
//
// A row with rule_type='builtin' is accepted and treated as a no-op reference:
// the built-in floor is unconditional, so such a row can neither add to nor
// subtract from it.
type Rule struct {
Name string `json:"name"`
Type string `json:"rule_type"`
Pattern string `json:"pattern"`View on GitHub (pinned to 3ee70a1026)