{"record":{"id":"9660891622bd20be","repo":"MyCATApache/Mycat-Server","slug":"columnvalue-columnvalue-please-eliminate-any-quo-966089","errorCode":null,"errorMessage":"columnValue:{columnValue} Please eliminate any quote and non number within it.","messagePattern":"columnValue:(.+?) Please eliminate any quote and non number within it\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/route/function/PartitionByRangeMod.java","lineNumber":78,"sourceCode":"\t\t\tlong value = Long.parseLong(columnValue);\n\t\t\tInteger rst = null;\n\t\t\tint nodeIndex = 0;\n\t\t\tfor (LongRange longRang : this.longRanges) {\n\t\t\t\tif (value <= longRang.valueEnd && value >= longRang.valueStart) {\n\t\t\t\t\tBigInteger bigNum = new BigInteger(columnValue).abs();\n\t\t\t\t\tint innerIndex = (bigNum.mod(BigInteger.valueOf(longRang.groupSize))).intValue();\n\t\t\t\t\treturn nodeIndex + innerIndex;\n\t\t\t\t} else {\n\t\t\t\t\tnodeIndex += longRang.groupSize;\n\t\t\t\t}\n\t\t\t}\n\t\t\t//数据超过范围，暂时使用配置的默认节点\n\t\t\tif (rst == null && defaultNode >= 0) {\n\t\t\t\treturn defaultNode;\n\t\t\t}\n\t\t\treturn rst;\n\t\t} catch (NumberFormatException e) {\n\t\t\tthrow new IllegalArgumentException(new StringBuilder().append(\"columnValue:\").append(columnValue).append(\" Please eliminate any quote and non number within it.\").toString(), e);\n\t\t}\n\t}\n    \n\t@Override\n\tpublic int getPartitionNum() {\n\t\tint nPartition = 0;\n\t\tfor(LongRange longRange : this.longRanges) {\n\t\t\tnPartition += longRange.groupSize;\n\t\t}\n\t\treturn nPartition;\n\t}\n\n\tpublic Integer calculateStart(String columnValue) {\n        long value = Long.parseLong(columnValue);\n        Integer rst = null;\n        int nodeIndex=0;\n        for (LongRange longRang : this.longRanges) {\n            if (value <= longRang.valueEnd && value >= longRang.valueStart) {","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/route/function/PartitionByRangeMod.java#L60-L96","documentation":"PartitionByRangeMod.calculate() converts the sharding column value to a long to locate the range and apply modulo. A NumberFormatException from Long.parseLong is rethrown as this IllegalArgumentException instructing the user to remove quotes and non-numeric characters from the value.","triggerScenarios":"calculate() is called with a non-numeric value: a string wrapped in quotes (\"'42'\"), alphanumeric IDs, values with spaces or separators, or empty/null strings that fail Long.parseLong.","commonSituations":"Sharding a VARCHAR column holding non-numeric data with a numeric range rule; ORM or SQL parser passing the literal including quotes; ETL delivering values with thousands separators ('1,000') or currency signs; users pointing a range-mod rule at a string key by mistake.","solutions":["Strip quotes and non-digit characters from the value before passing it to calculate().","Confirm the sharding column is numeric; if not, choose a string-compatible partition function.","Where feasible, configure the table column as a numeric type so the driver/parser delivers unquoted values.","Catch IllegalArgumentException in the routing layer and surface the raw columnValue in the client error for diagnosis."],"exampleFix":"// before\ncalculate(\" 1001x\"); // IllegalArgumentException\n// after\ncalculate(\"1001x\".replaceAll(\"[^0-9-]\", \"\")); // 1001, routes normally","handlingStrategy":"validation","validationCode":"if (columnValue == null || !columnValue.toString().trim().matches(\"-?\\\\d+\")) throw new IllegalArgumentException(\"range-mod sharding needs a numeric value: \" + columnValue);","typeGuard":"Long asLong(Object v) {\n  if (v == null) return null;\n  try { return Long.valueOf(v.toString().trim().replace(\"'\", \"\")); }\n  catch (NumberFormatException e) { return null; }\n}","tryCatchPattern":"try { idx = rule.calculate(value); } catch (IllegalArgumentException e) { /* clean the value or route to defaultNode; log raw value */ }","preventionTips":["Only assign PartitionByRangeMod to numeric columns.","Strip quotes and whitespace from string values before routing.","Use the rule's defaultNode for out-of-range values to avoid hard failures where business-appropriate."],"tags":["number-format","sharding","input-validation"],"backgroundTag":"invalid-argument-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"}