{"record":{"id":"e075e6d29aa01cdc","repo":"alibaba/spring-ai-alibaba","slug":"no-default-detector-for-pii-type-type","errorCode":null,"errorMessage":"No default detector for PII type: ${type}","messagePattern":"No default detector for PII type: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spring-ai-alibaba-agent-framework/src/main/java/com/alibaba/cloud/ai/graph/agent/hook/pii/PIIDetectionHook.java","lineNumber":307,"sourceCode":"\tprivate String hashValue(String value) {\n\t\tint hash = value.hashCode();\n\t\treturn String.format(\"<%s_hash:%08x>\", piiType.name().toLowerCase(), hash);\n\t}\n\n\tprivate PIIDetector getDefaultDetector(PIIType type) {\n\t\tswitch (type) {\n\t\tcase EMAIL:\n\t\t\treturn PIIDetectors.emailDetector();\n\t\tcase CREDIT_CARD:\n\t\t\treturn PIIDetectors.creditCardDetector();\n\t\tcase IP:\n\t\t\treturn PIIDetectors.ipDetector();\n\t\tcase MAC_ADDRESS:\n\t\t\treturn PIIDetectors.macAddressDetector();\n\t\tcase URL:\n\t\t\treturn PIIDetectors.urlDetector();\n\t\tdefault:\n\t\t\tthrow new IllegalArgumentException(\"No default detector for PII type: \" + type);\n\t\t}\n\t}\n\n\t@Override\n\tpublic String getName() {\n\t\treturn \"PIIDetection[\" + piiType.name() + \"]\";\n\t}\n\n\t@Override\n\tpublic List<JumpTo> canJumpTo() {\n\t\treturn List.of();\n\t}\n\n\tprivate static class ProcessResult {\n\t\tfinal String redactedText;\n\t\tfinal boolean hasMatches;\n\t\tfinal List<PIIMatch> matches;\n","sourceCodeStart":289,"sourceCodeEnd":325,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-agent-framework/src/main/java/com/alibaba/cloud/ai/graph/agent/hook/pii/PIIDetectionHook.java#L289-L325","documentation":"PIIDetectionHook.getDefaultDetector() maps each supported PIIType to a built-in detector (email, phone, IP, MAC, URL, etc.). If a PIIType enum value has no default detector registered, the constructor fails fast with IllegalArgumentException rather than building a hook that can never match anything.","triggerScenarios":"Constructing PIIDetectionHook (directly or via builder) with a PIIType value not covered by the default detector switch, or passing null/unknown type; typically after adding a new enum constant to PIIType without a detector.","commonSituations":"Using a newly added PIIType constant from a newer library version with an older hook implementation; providing a custom detector registry that omits a type; typos resolved to an unexpected enum member.","solutions":["Use a PIIType with a built-in default detector (EMAIL, PHONE, IP, MAC_ADDRESS, URL, etc.).","Register/override a custom detector for the unsupported type via the hook builder instead of relying on defaults.","Upgrade or align the library version so the enum and detector implementations match."],"exampleFix":"// before\nPIIDetectionHook hook = PIIDetectionHook.builder().piiType(PIIType.CUSTOM_TOKEN).build(); // no default\n// after\nPIIDetectionHook hook = PIIDetectionHook.builder().piiType(PIIType.EMAIL).build();","handlingStrategy":"validation","validationCode":"Set<PIIType> supported = Set.of(PIIType.EMAIL, PIIType.PHONE, PIIType.IP, PIIType.MAC_ADDRESS, PIIType.URL);\nif (!supported.contains(piiType)) {\n    throw new IllegalArgumentException(piiType + \" has no default detector; register a custom one\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    hook = PIIDetectionHook.builder().piiType(piiType).build();\n} catch (IllegalArgumentException e) {\n    // fall back to a supported type or register custom detector\n}","preventionTips":["Pin library versions so PIIType enum and detectors match","Check release notes when new PIIType constants appear","Register custom detectors for any non-default types"],"tags":["java","pii","detector","unsupported-enum","configuration"],"backgroundTag":"unsupported-enum-value","analyzedSha":"f82da0b50f35744c13968191be2b1cd2452ef550","analyzedAt":"2026-09-09T15:32:42.421Z","contentChangedAt":"2026-09-09T15:32:42.421Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}