{"record":{"id":"e346d3655f033c5b","repo":"alibaba/spring-cloud-alibaba","slug":"unexpected-character","errorCode":null,"errorMessage":"Unexpected character: {}","messagePattern":"Unexpected character: (.+?)","errorType":"exception","errorClass":"ParseException","httpStatus":null,"severity":"error","filePath":"spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-schedulerx/src/main/java/com/alibaba/cloud/scheduling/schedulerx/util/CronExpression.java","lineNumber":504,"sourceCode":"\t\telse if (c >= '0' && c <= '9') {\n\t\t\tint val = Integer.parseInt(String.valueOf(c));\n\t\t\ti++;\n\t\t\tif (i >= s.length()) {\n\t\t\t\taddToSet(val, -1, -1, type);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tc = s.charAt(i);\n\t\t\t\tif (c >= '0' && c <= '9') {\n\t\t\t\t\tfinal ValueSet vs = getValue(val, s, i);\n\t\t\t\t\tval = vs.value;\n\t\t\t\t\ti = vs.pos;\n\t\t\t\t}\n\t\t\t\ti = checkNext(i, s, val, type);\n\t\t\t\treturn i;\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tthrow new ParseException(\"Unexpected character: \" + c, i);\n\t\t}\n\n\t\treturn i;\n\t}\n\n\tprotected int checkNext(final int pos, final String s, final int val, final int type)\n\t\t\tthrows ParseException {\n\n\t\tint end = -1;\n\t\tint i = pos;\n\n\t\tif (i >= s.length()) {\n\t\t\taddToSet(val, end, -1, type);\n\t\t\treturn i;\n\t\t}\n\n\t\tchar c = s.charAt(pos);\n","sourceCodeStart":486,"sourceCodeEnd":522,"githubUrl":"https://github.com/alibaba/spring-cloud-alibaba/blob/115d5901102009492e05d5ec18c3f79cad4077d0/spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-schedulerx/src/main/java/com/alibaba/cloud/scheduling/schedulerx/util/CronExpression.java#L486-L522","documentation":"Thrown when a field token's first character is none of '?', '*', '/', 'L', or a digit (guard at CronExpression.java:503-504, the final else of storeExpressionVals). The parser cannot begin a field with an operator like '-', 'W', '#', or an unrecognized letter. It is a checked ParseException from the constructor.","triggerScenarios":"`new CronExpression(\"0 0 0 # * ?\")` (day-of-month starts with '#'), or `0 0 0 - * ?`, or `0 0 0 W * ?`, or any non-recognized leading char such as `0 0 0 X * ?`.","commonSituations":"Operators ('W', '#', 'L') placed at the start of a field instead of after a value (e.g. 'W15' written as 'W' alone), stray punctuation, or non-ASCII/letter typos. Also locale/encoding artifacts in config files.","solutions":["Move the operator after a numeric value, e.g. '#1' -> '5#1', 'W' -> '15W'.","Remove stray characters; a field must start with '?', '*', '/', 'L', or a digit.","Check the cron string encoding (ASCII) and field separators (single spaces)."],"exampleFix":"// before\nnew CronExpression(\"0 0 0 # * ?\");\n// after\nnew CronExpression(\"0 0 0 ? * 6#3\"); // 3rd Friday of the month","handlingStrategy":"validation","validationCode":"// Every field token must start with '?', '*', '/', 'L', or a digit.\nprivate static final Pattern FIELD_START = Pattern.compile(\"^[?*/L0-9]\");\nstatic boolean allFieldStartsValid(String cron) {\n    if (cron == null || cron.trim().isEmpty()) return false;\n    for (String f : cron.trim().split(\"\\\\s+\")) {\n        if (!FIELD_START.matcher(f).find()) return false;\n    }\n    return true;\n}","typeGuard":null,"tryCatchPattern":"try {\n    CronExpression cron = new CronExpression(raw);\n} catch (ParseException e) {\n    throw new IllegalArgumentException(\"Invalid cron expression: \" + raw, e);\n}","preventionTips":["Operators (W, #, -) must follow a value, not start a field.","Keep cron config ASCII and single-space separated.","Reject stray punctuation at config-load time."],"tags":["cron","schedulerx","spring-cloud-alibaba","configuration","parsing","validation"],"backgroundTag":null,"analyzedSha":"115d5901102009492e05d5ec18c3f79cad4077d0","analyzedAt":"2026-08-14T04:47:13.900Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}