{"record":{"id":"cc90a26e853454ef","repo":"agentscope-ai/agentscope","slug":"expected-a-5-field-cron-expression-got-record-da","errorCode":null,"errorMessage":"Expected a 5-field cron expression, got {record.data.cron_expression!r}","messagePattern":"Expected a 5-field cron expression, got (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/agentscope/app/_manager/_scheduler/_scheduler_manager.py","lineNumber":316,"sourceCode":"        \"\"\"\n\n        from apscheduler.triggers.cron import CronTrigger\n\n        logger.info(\n            \"Registering schedule %s(%s) cron=%s tz=%s\",\n            record.id,\n            record.data.name,\n            record.data.cron_expression,\n            record.data.timezone,\n        )\n\n        # ``CronTrigger.from_crontab`` is a thin helper that only forwards\n        # the 5 parsed fields and ``timezone`` — it has no parameter for\n        # ``start_date`` / ``end_date``.  Parse the expression ourselves so\n        # the configured activation window is honoured.\n        fields = record.data.cron_expression.split()\n        if len(fields) != 5:\n            raise ValueError(\n                \"Expected a 5-field cron expression, got \"\n                f\"{record.data.cron_expression!r}\",\n            )\n        minute, hour, day, month, day_of_week = fields\n\n        trigger = self._build_trigger(record)\n        job = self._scheduler.add_job(\n            trigger,\n            trigger=CronTrigger(\n                minute=minute,\n                hour=hour,\n                day=day,\n                month=month,\n                day_of_week=day_of_week,\n                timezone=record.data.timezone,\n                start_date=record.data.started_at,\n                end_date=record.data.ended_at,\n            ),","sourceCodeStart":298,"sourceCodeEnd":334,"githubUrl":"https://github.com/agentscope-ai/agentscope/blob/e90f1c7592896cc95f6e5ee506194f533378247d/src/agentscope/app/_manager/_scheduler/_scheduler_manager.py#L298-L334","documentation":"The scheduler parses cron expressions manually (because CronTrigger.from_crontab cannot pass start_date/end_date) and requires exactly 5 whitespace-separated fields: minute hour day month day-of-week. Any other count raises this ValueError.","triggerScenarios":"Registering or updating a schedule whose cron_expression has 6 fields (with seconds, the Quartz-style format) or 4/fewer fields, e.g. '0 0 12 * * ?' or '* * * *'.","commonSituations":"Copy-pasting a 6-field Quartz cron from a Java/Spring config or AWS EventBridge example; using a UI cron picker that emits seconds; malformed/truncated cron strings in stored schedule records during restore.","solutions":["Convert to standard 5-field cron: drop the leading seconds field","Replace Quartz-only tokens: '?' -> '*', and avoid day-of-week names unsupported by your parser version","Validate cron fields client-side before submitting a schedule"],"exampleFix":"# before\nschedule.cron_expression = \"0 0 12 * * ?\"  # 6 fields (Quartz)\n\n# after\nschedule.cron_expression = \"0 12 * * *\"  # 5 fields: min hour dom mon dow","handlingStrategy":"validation","validationCode":"def valid_cron(expr: str) -> bool:\n    return len(expr.split()) == 5","typeGuard":null,"tryCatchPattern":"try:\n    await scheduler.register_schedule(record)\nexcept ValueError as e:\n    if \"5-field cron\" in str(e):\n        record.data.cron_expression = \" \".join(expr.split()[1:])  # drop seconds","preventionTips":["Standardize on 5-field cron in all configs and UIs","Reject 6-field Quartz expressions at input time","Replace '?' with '*' when importing Java-style crons"],"tags":["agentscope","scheduler","cron","validation"],"backgroundTag":"invalid-cron-expression","analyzedSha":"e90f1c7592896cc95f6e5ee506194f533378247d","analyzedAt":"2026-08-28T18:24:12.087Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}