{"record":{"id":"3d9263043e5f723d","repo":"alibaba/spring-ai-alibaba","slug":"invalid-params-3d9263","errorCode":"INVALID_PARAMS","errorMessage":"expected type is ${type} but not match the current value type.","messagePattern":"expected type is (.+?) but not match the current value type\\.","errorType":"error_code","errorClass":"BizException","httpStatus":null,"severity":"error","filePath":"spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-core/src/main/java/com/alibaba/cloud/ai/studio/core/utils/common/VariableUtils.java","lineNumber":323,"sourceCode":"\t\t\telse if (ParameterTypeEnum.ARRAY_BOOLEAN.getCode().equals(type)) {\n\t\t\t\tif (value instanceof List) {\n\t\t\t\t\treturn value;\n\t\t\t\t}\n\t\t\t\telse if (value instanceof String) {\n\t\t\t\t\treturn JsonUtils.fromJsonToList((String) value, Boolean.class);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (ParameterTypeEnum.ARRAY_FILE.getCode().equals(type)) {\n\t\t\t\tif (value instanceof List) {\n\t\t\t\t\treturn value;\n\t\t\t\t}\n\t\t\t\telse if (value instanceof String) {\n\t\t\t\t\treturn JsonUtils.fromJsonToList((String) value, File.class);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tcatch (Exception e) {\n\t\t\tthrow new BizException(ErrorCode.INVALID_PARAMS.toError(key,\n\t\t\t\t\t\"expected type is \" + type + \" but not match the current value type.\"));\n\t\t}\n\t\tthrow new BizException(ErrorCode.INVALID_PARAMS.toError(key,\n\t\t\t\t\"expected type is \" + type + \" but not match the current value type.\"));\n\t}\n\n\t/**\n\t * Identifies variables from text content (ordered, non-unique)\n\t */\n\tpublic static List<String> identifyVariableListFromText(String content) {\n\t\tList<String> result = Lists.newArrayList();\n\t\tif (StringUtils.isBlank(content)) {\n\t\t\treturn result;\n\t\t}\n\t\tMatcher matcher = VAR_EXPR_PATTERN.matcher(content);\n\t\t// 查找并添加匹配的内容\n\t\twhile (matcher.find()) {\n\t\t\tresult.add(matcher.group(1));","sourceCodeStart":305,"sourceCodeEnd":341,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-core/src/main/java/com/alibaba/cloud/ai/studio/core/utils/common/VariableUtils.java#L305-L341","documentation":"VariableUtils.convertValueByType converts a raw variable value (string/JSON) into the declared target type. When conversion fails — bad JSON, wrong shape, incompatible value — the catch block (or the fall-through) throws BizException with code INVALID_PARAMS naming the expected type.","triggerScenarios":"Calling convertValueByType with a value that cannot be converted to the requested type: non-JSON string for a list/object target, numeric string for a non-numeric type, malformed File JSON for File targets, or null/unconvertible input reaching the final throw.","commonSituations":"Workflow variable substitution where upstream node output type differs from declared variable type; users typing values in admin UI forms that don't match configured types; JSON stored with extra quoting or truncation.","solutions":["Log/inspect the actual value and the declared type; fix the value to match the expected type","Validate/parse the value with JsonUtils before assignment to catch malformed JSON early","Correct the variable's declared type to match the real data shape","Wrap the call site in a try-catch for BizException and surface a user-friendly message identifying the offending key"],"exampleFix":"// before\nObject v = VariableUtils.convertValueByType(\"ids\", \"List\", \"not-json\");\n// after\nString raw = \"[\\\"a\\\",\\\"b\\\"]\";\nif (!JsonUtils.isJsonArray(raw)) {\n    throw new IllegalArgumentException(\"ids must be a JSON array\");\n}\nObject v = VariableUtils.convertValueByType(\"ids\", \"List\", raw);","handlingStrategy":"try-catch","validationCode":"boolean canConvert(String type, Object value) {\n    try {\n        VariableUtils.convertValueByType(\"__probe__\", type, value);\n        return true;\n    } catch (Exception e) {\n        return false;\n    }\n}","typeGuard":"boolean isJsonString(Object v) { return v instanceof String s && (s.startsWith(\"{\") || s.startsWith(\"[\")); }","tryCatchPattern":"try {\n    Object v = VariableUtils.convertValueByType(key, type, value);\n} catch (BizException e) {\n    if (ErrorCode.INVALID_PARAMS.name().equals(e.getCode())) {\n        log.warn(\"Variable {} cannot be converted to {}: {}\", key, type, value);\n    }\n}","preventionTips":["Declare variable types to match actual upstream output","JSON-encode structured values before assignment","Probe-convert in tests for all workflow variable mappings"],"tags":["variables","type-conversion","invalid-params"],"backgroundTag":"type-mismatch","analyzedSha":"f82da0b50f35744c13968191be2b1cd2452ef550","analyzedAt":"2026-09-09T15:32:42.421Z","contentChangedAt":"2026-09-09T15:32:42.421Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}