{"record":{"id":"e2ea20d7adced7b2","repo":"MyCATApache/Mycat-Server","slug":"function-is-not-in-right-format","errorCode":null,"errorMessage":"Function is not in right format!","messagePattern":"Function is not in right format!","errorType":"exception","errorClass":"SQLNonTransientException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/route/parser/primitive/FunctionParser.java","lineNumber":103,"sourceCode":"                    buffer.append(current);\n                    break;\n                case Commons.QUOTE:\n                    if (flag == 0) {\n                        flag = 1;\n                    } else if (flag == 1) {\n                        flag = 3;\n                    }\n                case Commons.DOUBLE_QUOTE:\n                    if (flag == 0) {\n                        flag = 2;\n                    } else if (flag == 2) {\n                        flag = 3;\n                    }\n                default:\n                    buffer.append(current);\n            }\n        }\n        throw new SQLNonTransientException(\"Function is not in right format!\");\n    }\n\n    public static List<String> getFields(Function function){\n        List<String> fields = new LinkedList<>();\n        for(Identifier identifier : function.getArguments()){\n            if(identifier instanceof Field){\n                fields.add(identifier.getName());\n            } else if (identifier instanceof Function){\n                fields.addAll(getFields((Function) identifier));\n            }\n        }\n        return fields;\n    }\n    public static void main(String[] args) throws SQLNonTransientException {\n        Function function = FunctionParser.parseFunction(\"function1(arg1,a.t,\\\"ast()\\\",function2(c.t,function3(x)))\");\n        System.out.println(getFields(function));\n    }\n}","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/route/parser/primitive/FunctionParser.java#L85-L121","documentation":"FunctionParser.parseFunction scans a function-definition string (rule function config) character by character expecting a specific structure of name/arguments (state machine with flags); if the loop ends without reaching the valid terminal state, it throws 'Function is not in right format!'. The configured function expression does not conform to the expected grammar.","triggerScenarios":"parseFunction is given a malformed function definition string — missing parentheses, unterminated argument list, stray characters, or arguments separated incorrectly — so the parse state machine finishes without returning a Function.","commonSituations":"Typo or wrong syntax in rule.xml / partition function expressions; copy-pasted config with missing commas or brackets; editing function arguments and leaving an unbalanced ')'.","solutions":["Fix the function string in the config to the documented format: name(arg1,arg2,...) with balanced parentheses and comma-separated arguments","Compare against a working example of the same function type in the docs/tests","Validate the config file with a syntax checker before loading; check for invisible characters/whitespace from copy-paste"],"exampleFix":"// before (rule.xml)\n<property name=\"function\">partition-hash-int(id 4</property>\n// after\n<property name=\"function\">partition-hash-int(id,4)</property>","handlingStrategy":"validation","validationCode":"if (!functionExpr.matches(\"[A-Za-z0-9_]+\\\\s*\\\\([^()]*\\\\)\")) {\n    throw new IllegalArgumentException(\"function config not in name(arg1,arg2,...) format: \" + functionExpr);\n}","typeGuard":null,"tryCatchPattern":"try { Function f = new FunctionParser().parseFunction(expr); } catch (SQLNonTransientException e) { if (\"Function is not in right format!\".equals(e.getMessage())) { /* fix rule.xml function string */ } }","preventionTips":["Validate rule.xml function strings against the documented grammar at deploy time","Check balanced parentheses/commas after manual edits","Copy function definitions from working examples in tests"],"tags":["config","parsing","sharding-rule"],"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"}