{"record":{"id":"69f7f26e554ef243","repo":"alibaba/spring-ai-alibaba","slug":"unexpected-value","errorCode":null,"errorMessage":"Unexpected value: ","messagePattern":"Unexpected value: ","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"spring-ai-alibaba-graph-core/src/main/java/com/alibaba/cloud/ai/graph/scheduling/ScheduledAgentTask.java","lineNumber":96,"sourceCode":"\t\t\t\t\t\tnew CronTrigger(config.getCronExpression()));\n\t\t\t\tbreak;\n\t\t\tcase FIXED_DELAY:\n\t\t\t\tscheduledFuture = taskScheduler.scheduleWithFixedDelay(this::executeGraph,\n\t\t\t\t\t\tInstant.now().plusMillis(config.getInitialDelay()), Duration.ofMillis(config.getFixedDelay()));\n\t\t\t\tbreak;\n\t\t\tcase FIXED_RATE:\n\t\t\t\tscheduledFuture = taskScheduler.scheduleAtFixedRate(this::executeGraph,\n\t\t\t\t\t\tInstant.now().plusMillis(config.getInitialDelay()), Duration.ofMillis(config.getFixedRate()));\n\t\t\t\tbreak;\n\t\t\tcase ONE_TIME:\n\t\t\t\tscheduledFuture = taskScheduler.schedule(this::executeGraph,\n\t\t\t\t\t\tInstant.now().plusMillis(config.getInitialDelay()));\n\t\t\t\tbreak;\n\t\t\tcase TRIGGER:\n\t\t\t\tscheduledFuture = taskScheduler.schedule(this::executeGraph, config.getTrigger());\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new IllegalStateException(\"Unexpected value: \" + config.getMode());\n\t\t}\n\n\t\tstarted = true;\n\t\tnotifyListeners(ScheduleLifecycleListener.ScheduleEvent.STARTED);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Stop the scheduled execution\n\t */\n\tpublic void stop() {\n\t\tif (scheduledFuture != null && !scheduledFuture.isCancelled()) {\n\t\t\tscheduledFuture.cancel(false);\n\t\t}\n\t\tstopped = true;\n\n\t\t// Unregister from active manager\n\t\tScheduledAgentManagerFactory.getInstance().getManager().unregisterTask(taskId);","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-graph-core/src/main/java/com/alibaba/cloud/ai/graph/scheduling/ScheduledAgentTask.java#L78-L114","documentation":"ScheduledAgentTask.start() switches over the ScheduleConfig mode (CRON, fixed rate/delay, TRIGGER); if the mode enum has an unexpected value not handled by any case (e.g. an unknown/added enum constant or corrupt config), the default branch throws IllegalStateException(\"Unexpected value: \" + mode).","triggerScenarios":"ScheduleConfig.getMode() returns an enum constant not covered by the switch — typically after the ScheduleMode enum gained a new value while this switch wasn't updated, or a manually constructed/invalid mode value.","commonSituations":"Library version upgrade adding a new ScheduleMode; custom config loading producing an unexpected mode; reflection/manual enum construction in tests.","solutions":["Upgrade spring-ai-alibaba-graph-core to a version whose start() handles your ScheduleMode value","Use only the documented ScheduleMode values (CRON, fixed-rate, fixed-delay, TRIGGER)","Check for classpath conflicts where two versions of the enum are loaded","If you added an enum value, add a corresponding case to the switch"],"exampleFix":"// before\ncase TRIGGER:\n    scheduledFuture = taskScheduler.schedule(this::executeGraph, config.getTrigger());\n    break;\n// after\ncase TRIGGER:\n    scheduledFuture = taskScheduler.schedule(this::executeGraph, config.getTrigger());\n    break;\ncase EVENT:\n    scheduledFuture = taskScheduler.schedule(this::executeGraph, config.getEventTrigger());\n    break;","handlingStrategy":"validation","validationCode":"// verify mode is a value handled by start()\nScheduleMode mode = config.getMode();\nif (mode != ScheduleMode.CRON && mode != ScheduleMode.FIXED_RATE\n        && mode != ScheduleMode.FIXED_DELAY && mode != ScheduleMode.TRIGGER) {\n    throw new IllegalArgumentException(\"unsupported schedule mode: \" + mode);\n}","typeGuard":null,"tryCatchPattern":"try {\n    task.start();\n} catch (IllegalStateException e) {\n    if (String.valueOf(e.getMessage()).startsWith(\"Unexpected value:\")) {\n        logger.error(\"ScheduleMode {} unsupported by this library version\", config.getMode());\n    } else throw e;\n}","preventionTips":["Use only documented ScheduleMode constants from the library version in use","Keep producer and consumer on the same spring-ai-alibaba version","After upgrading, check release notes for new enum values","Avoid deserializing ScheduleMode from untrusted config without validation"],"tags":["illegal-state","enum","switch","scheduling"],"backgroundTag":"unsupported-enum-value","analyzedSha":"f82da0b50f35744c13968191be2b1cd2452ef550","analyzedAt":"2026-09-09T15:32:42.421Z","contentChangedAt":"2026-09-09T15:32:42.421Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}