{"record":{"id":"63d399b24eb80f6f","repo":"paascloud/paascloud-master","slug":"error-63d399","errorCode":null,"errorMessage":"钉钉机器人消息类型错误","messagePattern":"钉钉机器人消息类型错误","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"paascloud-provider/paascloud-provider-opc/src/main/java/com/paascloud/provider/web/rpc/DingtalkFeignClient.java","lineNumber":127,"sourceCode":"\t\t} else if (RobotMsgTypeEnum.TEXT.getName().equals(msgType)) {\n\t\t\tTextDto text = chatRobotMsgDto.getText();\n\t\t\tAtDto at = chatRobotMsgDto.getAt();\n\t\t\tString content = text.getContent();\n\n\t\t\tPreconditions.checkArgument(PublicUtil.isNotEmpty(text), \"text类型消息体空\");\n\t\t\tPreconditions.checkArgument(PublicUtil.isNotEmpty(content), \"text类型消息体内容为空\");\n\n\t\t\tif (PublicUtil.isNotEmpty(at)) {\n\t\t\t\tString[] atMobiles = at.getAtMobiles();\n\t\t\t\tif (PublicUtil.isNotEmpty(atMobiles)) {\n\t\t\t\t\tfor (String atMobile : atMobiles) {\n\t\t\t\t\t\tPreconditions.checkArgument(ValidateUtil.isMobileNumber(atMobile), \"手机号码:\" + atMobile + \"格式错误\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t} else {\n\t\t\tthrow new IllegalArgumentException(\"钉钉机器人消息类型错误\");\n\t\t}\n\t}\n}\n","sourceCodeStart":109,"sourceCodeEnd":131,"githubUrl":"https://github.com/paascloud/paascloud-master/blob/781281a9503332ed3cef44ea618349d14230a127/paascloud-provider/paascloud-provider-opc/src/main/java/com/paascloud/provider/web/rpc/DingtalkFeignClient.java#L109-L131","documentation":"A plain IllegalArgumentException ('钉钉机器人消息类型错误') thrown by DingtalkFeignClient.checkChatReBotMsg when the message object passed to sendChatRobotMsg has a msgtype that is not one of the supported Dingtalk robot message types handled by the validation branches (text, link, markdown, actionCard, feedCard, etc.). It is a programmer-error guard against unsupported/misspelled message types.","triggerScenarios":"Calling sendChatRobotMsg with a DingtalkMessage whose type field is null, empty, misspelled (e.g. \"text \" with trailing space or \"Text\" wrong case), or an unsupported type not covered by checkChatReBotMsg's if/else chain.","commonSituations":"Copy-pasting a message builder from another codebase with a different type string; adding a new Dingtalk message type upstream without extending the client's validation; forgetting to set the type field entirely.","solutions":["Set the message type to an exact supported value (e.g. \"text\", \"link\", \"markdown\", \"actionCard\", \"feedCard\") before calling sendChatRobotMsg.","Log/inspect the msgtype actually sent; check case and whitespace.","If a genuinely new Dingtalk type is needed, extend checkChatReBotMsg with a validation branch for it.","Use an enum or constants class for Dingtalk message types instead of raw strings to prevent typos.","Validate the type client-side before constructing the message."],"exampleFix":"// before: free-form string type\nDingtalkMessage msg = new DingtalkMessage();\nmsg.setMsgtype(\"Text\"); // IllegalArgumentException\n// after: use the exact supported value / constant\nDingtalkMessage msg = new DingtalkMessage();\nmsg.setMsgtype(DingtalkConstants.MSG_TYPE_TEXT); // \"text\"\ndingtalkFeignClient.sendChatRobotMsg(msg);","handlingStrategy":"validation","validationCode":"private static final Set<String> SUPPORTED_TYPES = Set.of(\"text\",\"link\",\"markdown\",\"actionCard\",\"feedCard\");\nif (msg.getMsgtype() == null || !SUPPORTED_TYPES.contains(msg.getMsgtype())) {\n    throw new IllegalArgumentException(\"Unsupported Dingtalk msgtype: \" + msg.getMsgtype());\n}","typeGuard":"boolean isSupportedDingtalkType(DingtalkMessage m) {\n    return m != null && m.getMsgtype() != null && SUPPORTED_TYPES.contains(m.getMsgtype().trim());\n}","tryCatchPattern":"try {\n    dingtalkFeignClient.sendChatRobotMsg(msg);\n} catch (IllegalArgumentException e) {\n    log.error(\"Dingtalk msg rejected: {}\", e.getMessage());\n    throw new BadRequestException(\"Unsupported Dingtalk message type\");\n}","preventionTips":["Define message types as an enum/constants, never raw strings.","Trim and lowercase the type before comparison.","Add validation for any new Dingtalk message type you introduce.","Unit-test sendChatRobotMsg for each supported type.","Never send a message without explicitly setting msgtype."],"tags":["dingtalk","validation","enum"],"backgroundTag":"invalid-enum-value","analyzedSha":"781281a9503332ed3cef44ea618349d14230a127","analyzedAt":"2026-09-10T10:59:02.070Z","contentChangedAt":"2026-09-10T10:59:02.070Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}