{"record":{"id":"832aa237eef272e2","repo":"MyCATApache/Mycat-Server","slug":"columnvalue-columnvalue-please-check-if-the-form","errorCode":null,"errorMessage":"columnValue:{columnValue} Please check if the format satisfied.","messagePattern":"columnValue:(.+?) Please check if the format satisfied\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/route/function/LatestMonthPartion.java","lineNumber":45,"sourceCode":"\t\tif (hourSpan * 24 < 24) {\n\t\t\tthrow new java.lang.IllegalArgumentException(\n\t\t\t\t\t\"invalid splitOnDay param:\"\n\t\t\t\t\t\t\t+ splitOneDay\n\t\t\t\t\t\t\t+ \" should be an even number and less or equals than 24\");\n\t\t}\n\t}\n\n\t@Override\n\tpublic Integer calculate(String columnValue)  {\n\t\ttry {\n\t\t\tint valueLen = columnValue.length();\n\t\t\tint day = Integer.parseInt(columnValue.substring(valueLen - 4,\n\t\t\t\t\tvalueLen - 2));\n\t\t\tint hour = Integer.parseInt(columnValue.substring(valueLen - 2));\n\t\t\tint dnIndex = (day - 1) * splitOneDay + hour / hourSpan;\n\t\t\treturn dnIndex;\n\t\t}catch (NumberFormatException e){\n\t\t\tthrow new IllegalArgumentException(new StringBuilder().append(\"columnValue:\").append(columnValue).append(\" Please check if the format satisfied.\").toString(),e);\n\t\t}\n\t}\n\n\tpublic Integer[] calculateRange(String beginValue, String endValue)  {\n\t\treturn calculateSequenceRange(this,beginValue, endValue);\n\t}\n\n}\n","sourceCodeStart":27,"sourceCodeEnd":54,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/route/function/LatestMonthPartion.java#L27-L54","documentation":"LatestMonthPartion.calculate parses the last four characters of the sharding value as a day and the last two as an hour to compute the partition index. Any NumberFormatException (bad date format) is rethrown as IllegalArgumentException asking the caller to check the value's format — it expects a string ending in DDHH (2-digit day, 2-digit hour) after the prefix length.","triggerScenarios":"calculate(columnValue) with a value whose trailing substring(valueLen-4, valueLen-2) or substring(valueLen-2) is not an integer — e.g. '2023010112' with wrong length, '2023xx011x', empty or shorter-than-4 strings.","commonSituations":"Sending full 'yyyyMMddHHmm' timestamps instead of the expected prefix+DDHH layout; passing null/short values; time-zone formatting differences adding 'T' or milliseconds; misconfigured valueLen so slicing lands on the wrong characters.","solutions":["Format the sharding key so the string ends with exactly 4 digits: 2-digit day of month (01-31) + 2-digit hour (00-23), matching valueLen.","Validate/normalize timestamps in the application before insert/query (e.g. DateTimeFormatter 'ddHH' suffix).","Verify rule.xml valueLen/splitOneDay configuration matches the actual column format.","Trim or strip separators ('-', 'T', ':') from the partition key value."],"exampleFix":"// before\nString key = \"2026-09-10 14:30\"; // parse fails\n// after\nString key = \"202609101430\"; // or ensure last 4 chars are e.g. \"1014\"\nString formatted = ts.format(DateTimeFormatter.ofPattern(\"MMddHH\"));","handlingStrategy":"validation","validationCode":"boolean isValidLatestMonthKey(String v, int valueLen) {\n    if (v == null || v.length() < valueLen || v.length() != valueLen) return false;\n    String suffix = v.substring(valueLen - 4);\n    return suffix.matches(\"\\\\d{2}(0[0-9]|1[0-9]|2[0-3])\") &&\n           Integer.parseInt(suffix.substring(0, 2)) >= 1;\n}","typeGuard":"Integer tryComputePartition(String v, int valueLen) {\n    try {\n        int day = Integer.parseInt(v.substring(valueLen - 4, valueLen - 2));\n        int hour = Integer.parseInt(v.substring(valueLen - 2));\n        return day; // valid parse\n    } catch (Exception e) { return null; }\n}","tryCatchPattern":"try {\n    insert(row);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"Please check if the format\")) {\n        LOGGER.error(\"bad LatestMonthPartion key: {}\", row.getKey());\n    } else { throw e; }\n}","preventionTips":["Format keys so the last 4 chars are DDHH with digits only","Match rule.xml valueLen/splitOneDay to the real column format","Validate timestamps with a DateTimeFormatter before send"],"tags":["sharding","date-format","partition","invalid-input"],"backgroundTag":"invalid-date-format","analyzedSha":"65f8d8beb752f935752f2a0eec0ab017facab9ef","analyzedAt":"2026-09-11T00:12:21.696Z","contentChangedAt":"2026-09-11T00:12:21.696Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}