{"record":{"id":"581e29de31d7d3ce","repo":"alibaba/spring-ai-alibaba","slug":"piitype-must-be-specified","errorCode":null,"errorMessage":"piiType must be specified","messagePattern":"piiType must be specified","errorType":"validation","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":373,"sourceCode":"\n\t\tpublic Builder applyToInput(boolean applyToInput) {\n\t\t\tthis.applyToInput = applyToInput;\n\t\t\treturn this;\n\t\t}\n\n\t\tpublic Builder applyToOutput(boolean applyToOutput) {\n\t\t\tthis.applyToOutput = applyToOutput;\n\t\t\treturn this;\n\t\t}\n\n\t\tpublic Builder applyToToolResults(boolean applyToToolResults) {\n\t\t\tthis.applyToToolResults = applyToToolResults;\n\t\t\treturn this;\n\t\t}\n\n\t\tpublic PIIDetectionHook build() {\n\t\t\tif (piiType == null) {\n\t\t\t\tthrow new IllegalArgumentException(\"piiType must be specified\");\n\t\t\t}\n\t\t\treturn new PIIDetectionHook(this);\n\t\t}\n\t}\n}\n\n","sourceCodeStart":355,"sourceCodeEnd":380,"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#L355-L380","documentation":"PIIDetectionHook.Builder.build() requires a piiType to be set; without one the hook would not know what to detect, so it throws IllegalArgumentException. This is a fail-fast validation at hook construction.","triggerScenarios":"Calling PIIDetectionHook.builder()...build() without calling .piiType(...) — e.g. building from dynamic config where the type key was absent.","commonSituations":"Configuration file or environment missing the PII type property; copy-pasted builder code with the piiType line removed; conditional builder flows that skip setting the type.","solutions":["Call .piiType(PIIType.XXX) on the builder before build().","Validate the config value feeding the builder is non-null before constructing the hook.","Provide a default PII type in configuration so the field is always populated."],"exampleFix":"// before\nPIIDetectionHook hook = PIIDetectionHook.builder().strategy(RedactionStrategy.BLOCK).build();\n// after\nPIIDetectionHook hook = PIIDetectionHook.builder().piiType(PIIType.EMAIL).strategy(RedactionStrategy.BLOCK).build();","handlingStrategy":"validation","validationCode":"PIIType type = config.getPiiType();\nif (type == null) {\n    throw new IllegalStateException(\"piiType is required in configuration\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Make piiType a required config key with startup validation","Default to a common type (e.g. EMAIL) in config templates","Keep builder calls together so piiType is not omitted"],"tags":["java","builder-validation","missing-required-argument","pii"],"backgroundTag":"missing-required-argument","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"}