{"record":{"id":"b5e3089eda988177","repo":"dianping/cat","slug":"not-match-s","errorCode":null,"errorMessage":"not match %s","messagePattern":"not match (.+?)","errorType":"validation","errorClass":"ParseException","httpStatus":null,"severity":"error","filePath":"cat-core/src/main/java/com/dianping/cat/config/DefaultFormat.java","lineNumber":47,"sourceCode":"\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)) {\n\t\t\t\t\treturn input;\n\t\t\t\t}\n\t\t\t}","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/dianping/cat/blob/e815e74d4c2dd74edac831241f1253fcc7d25381/cat-core/src/main/java/com/dianping/cat/config/DefaultFormat.java#L29-L65","documentation":"Thrown by DefaultFormat.parse when the input string's length does not equal the length declared after ':' in the pattern (e.g. pattern 'md5:32' but input has 31 characters). This is a strict length check applied before the item-specific validation; it throws java.text.ParseException with 'not match <pattern>'.","triggerScenarios":"DefaultFormat.parse(input, \"name:N\") where input.length() != N. Typical: 'md5:32' fed a truncated hash, 'number:4' fed a 3-digit cluster, or fixed-width tokens read from a path where one segment lost or gained characters.","commonSituations":"Parsing URL paths or message-id components against a fixed-width format where data is malformed (lowercase md5 of wrong length, zero-padded fields stripped), or a format config updated to a new width while the data still has the old width.","solutions":["Print the input and pattern from the exception context; compare input.length() with the declared length.","Fix the data producer if the token is genuinely malformed (e.g. re-generate the full 32-char md5).","Adjust the pattern length to match the real token width if the config width was wrong.","Remove the length constraint (drop ':N') if the field is variable-width and only type checking (md5/number) is needed."],"exampleFix":"// before\nformat.parse(\"d41d8cd98f00b204e9800998ecf8427\", \"md5:32\"); // 31 chars -> not match\n\n// after\nformat.parse(\"d41d8cd98f00b204e9800998ecf8427e\", \"md5:32\"); // full 32-char md5","handlingStrategy":"validation","validationCode":"int colon = pattern.indexOf(':');\nif (colon > -1 && pattern.length() > colon + 1) {\n    int want = Integer.parseInt(pattern.substring(colon + 1));\n    if (input.length() != want) skipOrLog(pattern, input);\n}","typeGuard":null,"tryCatchPattern":"catch (ParseException e) { /* length mismatch: skip bad record, count it, keep batch alive */ }","preventionTips":["Validate record widths at ingestion before format parsing.","Monitor skip counters so upstream data drift is visible early."],"tags":["parsing","validation","format-string"],"backgroundTag":null,"analyzedSha":"e815e74d4c2dd74edac831241f1253fcc7d25381","analyzedAt":"2026-08-14T14:22:34.512Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}