{"record":{"id":"7eea8a5f06b52530","repo":"dianping/cat","slug":"sis-illegal","errorCode":null,"errorMessage":"%sis illegal","messagePattern":"(.+?)is illegal","errorType":"validation","errorClass":"ParseException","httpStatus":null,"severity":"error","filePath":"cat-core/src/main/java/com/dianping/cat/config/DefaultFormat.java","lineNumber":44,"sourceCode":"\t}\n\n\t@Override\n\tpublic String parse(String input) throws ParseException {\n\t\tString pattern = getPattern();\n\t\tString item = \"\";\n\t\tString describe = \"\";\n\t\tint index = pattern.indexOf(\":\");\n\n\t\tif (index != -1 && pattern.length() > index + 1) {\n\t\t\titem = pattern.substring(0, index).trim();\n\t\t\tdescribe = pattern.substring(index + 1).trim();\n\t\t}\n\t\tif (!describe.isEmpty()) {\n\t\t\tint length = 1;\n\t\t\ttry {\n\t\t\t\tlength = Integer.parseInt(describe);\n\t\t\t} catch (NumberFormatException e) {\n\t\t\t\tthrow new ParseException(pattern + \"is illegal\", 0);\n\t\t\t}\n\t\t\tif (input.length() != length) {\n\t\t\t\tthrow new ParseException(\"not match \" + pattern, 0);\n\t\t\t}\n\t\t}\n\t\tif (pattern.equals(\"*\")) {\n\t\t\treturn input;\n\t\t} else if (item.equals(\"md5\")) {\n\t\t\tchar[] charArray = input.toCharArray();\n\t\t\tfor (Character ch : charArray) {\n\t\t\t\tif (!Character.isDigit(ch) && !Character.isLowerCase(ch)) {\n\t\t\t\t\treturn input;\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (item.equals(\"number\")) {\n\t\t\tchar[] charArray = input.toCharArray();\n\t\t\tfor (Character ch : charArray) {\n\t\t\t\tif (!Character.isDigit(ch)) {","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/dianping/cat/blob/e815e74d4c2dd74edac831241f1253fcc7d25381/cat-core/src/main/java/com/dianping/cat/config/DefaultFormat.java#L26-L62","documentation":"Thrown by DefaultFormat.parse when the ':'-suffixed length descriptor inside a format pattern is not a parsable integer. Patterns look like 'name:length' (e.g. 'md5:32'); the part after the colon must be a pure digit string. A java.text.ParseException (not RuntimeException) is thrown with the offending pattern appended.","triggerScenarios":"Calling DefaultFormat.parse(input, pattern) or the parse(Map,...) overload with a pattern whose suffix after ':' contains non-digits, e.g. 'city:abc', 'ip:32x', or a stray colon like 'type:'. Note 'type:' (empty describe) is tolerated; only a non-empty non-numeric describe triggers this.","commonSituations":"Hand-edited format strings in CAT content/config files (e.g. path format definitions for domain/ip/cluster rules) where someone writes a label or typo after the colon instead of a length; upgrading configs that changed pattern syntax.","solutions":["Inspect the exact pattern string in the ParseException message and check the segment after the first ':'.","Change the suffix to the expected field length (digits only), e.g. 'md5:32', 'number:1'.","If no length constraint is wanted, drop the colon entirely: 'md5' instead of 'md5:x'.","Validate format patterns at startup (regex like ^[^:]+(:\\d+)?$) so bad config fails fast with a clear location."],"exampleFix":"// before\nformat.parse(\"192.168.1.1\", \"ip:address\"); // ParseException: ip:addressis illegal\n\n// after\nformat.parse(\"192.168.1.1\", \"ip:15\");","handlingStrategy":"validation","validationCode":"private static final Pattern P = Pattern.compile(\"^[^:]+(:\\\\d+)?$\");\nif (!P.matcher(pattern).matches()) throw new IllegalArgumentException(\"Bad format pattern: \" + pattern);","typeGuard":null,"tryCatchPattern":"catch (ParseException e) { log.error(\"bad pattern {}\", pattern); fail startup; }","preventionTips":["Validate every format pattern at config load time, not per record.","Keep a regex like ^[^:]+(:\\d+)?$ as documentation of legal syntax."],"tags":["configuration","parsing","format-string"],"backgroundTag":null,"analyzedSha":"e815e74d4c2dd74edac831241f1253fcc7d25381","analyzedAt":"2026-08-14T14:22:34.512Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}