{"record":{"id":"3305a50cfa6a0a76","repo":"xuxueli/xxl-job","slug":"unexpected-character","errorCode":null,"errorMessage":"Unexpected character: {}","messagePattern":"Unexpected character: (.+?)","errorType":"validation","errorClass":"ParseException","httpStatus":null,"severity":"error","filePath":"xxl-job-admin/src/main/java/com/xxl/job/admin/business/scheduler/cron/CronExpression.java","lineNumber":720,"sourceCode":"            }\n            return i;\n        } else if (c >= '0' && c <= '9') {\n            int val = Integer.parseInt(String.valueOf(c));\n            i++;\n            if (i >= s.length()) {\n                addToSet(val, -1, -1, type);\n            } else {\n                c = s.charAt(i);\n                if (c >= '0' && c <= '9') {\n                    ValueSet vs = getValue(val, s, i);\n                    val = vs.value;\n                    i = vs.pos;\n                }\n                i = checkNext(i, s, val, type);\n                return i;\n            }\n        } else {\n            throw new ParseException(\"Unexpected character: \" + c, i);\n        }\n\n        return i;\n    }\n\n    private void checkIncrementRange(int incr, int type, int idxPos) throws ParseException {\n        if (incr > 59 && (type == SECOND || type == MINUTE)) {\n            throw new ParseException(\"Increment >= 60 : \" + incr, idxPos);\n        } else if (incr > 23 && (type == HOUR)) {\n            throw new ParseException(\"Increment >= 24 : \" + incr, idxPos);\n        } else if (incr > 31 && (type == DAY_OF_MONTH)) {\n            throw new ParseException(\"Increment >= 31 : \" + incr, idxPos);\n        } else if (incr > 7 && (type == DAY_OF_WEEK)) {\n            throw new ParseException(\"Increment >= 7 : \" + incr, idxPos);\n        } else if (incr > 12 && (type == MONTH)) {\n            throw new ParseException(\"Increment >= 12 : \" + incr, idxPos);\n        }\n    }","sourceCodeStart":702,"sourceCodeEnd":738,"githubUrl":"https://github.com/xuxueli/xxl-job/blob/e74c784f68f81fa89cb350913ef15794865d7b12/xxl-job-admin/src/main/java/com/xxl/job/admin/business/scheduler/cron/CronExpression.java#L702-L738","documentation":"This is the catch-all for any character in a cron field that the parser does not recognize. The parser handles '?', '*', '/', 'L', and digits 0-9; any other character (e.g., letters other than 'L', symbols like '&', '%', '!') triggers this error.","triggerScenarios":"A cron field containing an invalid character such as '0 & * * * ?' (ampersand in seconds), 'x * * * * ?', or any stray symbol. The else branch at line 720 fires when none of the preceding character checks match.","commonSituations":"Encoding issues, invisible characters pasted from a rich-text source, or using a non-Quartz cron dialect that uses different syntax (e.g., '@daily' macro or named days like 'MON' without proper field context).","solutions":["Inspect the cron string for stray or non-ASCII characters and remove them.","Replace named-day or macro syntax with Quartz-compatible numeric cron tokens.","Run the raw string through a character-level check to detect non-printable characters before parsing."],"exampleFix":"// before\n\"0 0 0 & * ?\"\n// after\n\"0 0 0 * * ?\"","handlingStrategy":"validation","validationCode":"// Only allow known cron characters in each field\nString allowed = \"0123456789*/-?LW#,\";\nfor (char ch : cron.toCharArray()) {\n    if (!Character.isWhitespace(ch) && allowed.indexOf(ch) == -1) {\n        throw new IllegalArgumentException(\"Invalid cron character: '\" + ch + \"'\");\n    }\n}","typeGuard":"boolean hasOnlyCronChars(String cron) {\n    for (char c : cron.toCharArray()) {\n        if (!Character.isWhitespace(c) && \"0123456789*/-?LW#,\".indexOf(c) == -1) return false;\n    }\n    return true;","tryCatchPattern":"try {\n    new CronExpression(sanitizedCron);\n} catch (ParseException e) {\n    if (e.getMessage().contains(\"Unexpected character\")) {\n        // strip non-cron characters and re-validate\n    }\n}","preventionTips":["Sanitize cron input to strip non-ASCII and invisible characters.","Provide a cron input widget that restricts typed characters to the valid set.","Test cron strings from external sources (APIs, config files) before parsing."],"tags":["cron","validation","syntax","parsing"],"backgroundTag":null,"analyzedSha":"e74c784f68f81fa89cb350913ef15794865d7b12","analyzedAt":"2026-08-14T04:22:43.715Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}