{"record":{"id":"7bea7afd814ab49d","repo":"alibaba/spring-ai-alibaba","slug":"jumpto-value-cannot-be-null","errorCode":null,"errorMessage":"JumpTo value cannot be null","messagePattern":"JumpTo value cannot be null","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spring-ai-alibaba-agent-framework/src/main/java/com/alibaba/cloud/ai/graph/agent/hook/JumpTo.java","lineNumber":54,"sourceCode":"\t@Override\n\t@JsonValue\n\tpublic String toString() {\n\t\treturn name();\n\t}\n\n\t/**\n\t * Converts a string to a JumpTo enum instance.\n\t * Supports case-insensitive matching.\n\t * Used for JSON deserialization via @JsonCreator annotation.\n\t * \n\t * @param value the string value to convert\n\t * @return the corresponding JumpTo enum instance\n\t * @throws IllegalArgumentException if the value does not match any enum constant\n\t */\n\t@JsonCreator\n\tpublic static JumpTo fromString(String value) {\n\t\tif (value == null) {\n\t\t\tthrow new IllegalArgumentException(\"JumpTo value cannot be null\");\n\t\t}\n\n\t\t// Try case-insensitive matching first\n\t\tfor (JumpTo jumpTo : values()) {\n\t\t\tif (jumpTo.name().equalsIgnoreCase(value)) {\n\t\t\t\treturn jumpTo;\n\t\t\t}\n\t\t}\n\n\t\t// If no match found, throw exception with helpful message\n\t\tthrow new IllegalArgumentException(\n\t\t\t\"Unknown JumpTo value: \" + value + \". Valid values are: tool, model, end\");\n\t}\n\n\t/**\n\t * Converts a string to a JumpTo enum instance, returning null if the value is null or invalid.\n\t * This is a safe version that doesn't throw exceptions.\n\t * ","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-agent-framework/src/main/java/com/alibaba/cloud/ai/graph/agent/hook/JumpTo.java#L36-L72","documentation":"JumpTo.fromString converts a string to the JumpTo enum (used by hooks to redirect control flow). It throws IllegalArgumentException when the input string is null, since null cannot match any enum constant.","triggerScenarios":"Calling JumpTo.fromString(null) directly, or deserializing JSON where the jump target field is null/absent and a @JsonCreator maps it through fromString.","commonSituations":"Hook result object missing the jumpTo field; JSON payload without the field; passing a nullable variable without checking it first.","solutions":["Pass a non-null string (\"tool\", \"model\", or \"end\") to fromString","Use JumpTo.fromStringOrNull when the value may be null","Default the field to a valid value before serialization"],"exampleFix":"// before\nJumpTo jump = JumpTo.fromString(hookResult.getJumpTo()); // may be null\n// after\nJumpTo jump = JumpTo.fromStringOrNull(hookResult.getJumpTo());","handlingStrategy":"try-catch","validationCode":"if (value == null) return null;\nif (java.util.Arrays.stream(JumpTo.values()).noneMatch(j -> j.name().equalsIgnoreCase(value))) return null;","typeGuard":"static JumpTo safeJump(String v) { return v == null ? null : JumpTo.fromStringOrNull(v); }","tryCatchPattern":"JumpTo jump;\ntry {\n    jump = JumpTo.fromString(value);\n} catch (IllegalArgumentException e) {\n    jump = JumpTo.END; // default\n}","preventionTips":["Prefer fromStringOrNull for possibly-null input","Provide defaults for missing jumpTo fields in hook JSON","Keep a whitelist of accepted strings at the API boundary"],"tags":["java","agent-framework","hooks","enum"],"backgroundTag":"null-argument","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"}