{"record":{"id":"71587a2add863a2d","repo":"chenhg5/cc-connect","slug":"tuitui-invalid-chat-type-q-71587a","errorCode":null,"errorMessage":"tuitui: invalid chat type %q","messagePattern":"tuitui: invalid chat type %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/tuitui/tuitui.go","lineNumber":657,"sourceCode":"\tpayload := map[string]any{\n\t\t\"msgtype\":        \"emoji_reaction\",\n\t\t\"tousers\":        []map[string]string{},\n\t\t\"togroups\":       []map[string]string{},\n\t\t\"toteams\":        []map[string]string{},\n\t\t\"emoji_reaction\": map[string]any{\"emoji\": emoji, \"cancel\": false},\n\t}\n\tswitch rctx.chatType {\n\tcase chatTypeDirect:\n\t\tpayload[\"tousers\"] = []map[string]string{{\"user\": rctx.chatID, \"msgid\": rctx.messageID}}\n\tcase chatTypeGroup:\n\t\tpayload[\"togroups\"] = []map[string]string{{\"group\": rctx.chatID, \"msgid\": rctx.messageID}}\n\tcase chatTypeChannel:\n\t\tteam := teamsParseChatID(rctx.chatID)\n\t\tteam[\"parent_id\"] = \"\"\n\t\tteam[\"post_id\"] = rctx.messageID\n\t\tpayload[\"toteams\"] = []map[string]string{team}\n\tdefault:\n\t\treturn fmt.Errorf(\"tuitui: invalid chat type %q\", rctx.chatType)\n\t}\n\treturn p.postJSON(ctx, \"/robot/message/custom/modify\", payload, nil)\n}\n\nfunc (p *Platform) sendMediaID(ctx context.Context, rctx replyContext, mediaID, filename string, isImage bool) error {\n\tpayload := map[string]any{}\n\tif rctx.chatType == chatTypeChannel {\n\t\tmarkdown := fmt.Sprintf(\"[%s]({{tuitui_file %q}})\", filename, mediaID)\n\t\tif isImage {\n\t\t\tmarkdown = fmt.Sprintf(\"![]({{tuitui_image %q}})\", mediaID)\n\t\t}\n\t\tpayload[\"msgtype\"] = \"richtext/markdown\"\n\t\tpayload[\"richtext\"] = map[string]string{\n\t\t\t\"markdown\":     markdown,\n\t\t\t\"delims_left\":  \"{{\",\n\t\t\t\"delims_right\": \"}}\",\n\t\t}\n\t} else if isImage {","sourceCodeStart":639,"sourceCodeEnd":675,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/tuitui/tuitui.go#L639-L675","documentation":"reactToMessage builds the /robot/message/custom/modify payload per chat type (direct, group, channel). If rctx.chatType is none of the known constants it cannot fill the right recipient field and rejects the request before any network call. chatType is usually derived from the reply context or guessed via guessChatType(chatID), so an empty/garbage value signals a bad reply context.","triggerScenarios":"Calling reactToMessage with a replyContext whose chatType is not one of the recognized constants (e.g. empty string when guessChatType returned nothing, or a misspelled chat type).","commonSituations":"Manually constructed replyContext with chatType left unset and a chatID format guessChatType does not recognize; a Tuitui API change introducing a new chat type the adapter doesn't know.","solutions":["Set chatType explicitly to the correct constant (chatTypeDirect/chatTypeGroup/chatTypeChannel) when building the replyContext.","Ensure the chatID uses a format guessChatType can parse (correct prefix) so the fallback guess works.","Log/print rctx.chatID and rctx.chatType to identify which value is being rejected, then correct it.","If a new chat type exists upstream, add a case for it in reactToMessage."],"exampleFix":"// before\nrctx := replyContext{ChatID: \"123\"} // chatType empty, guess fails\n// after\nrctx := replyContext{ChatID: \"grp_123\", ChatType: chatTypeGroup}","handlingStrategy":"validation","validationCode":"switch rctx.chatType {\ncase chatTypeDirect, chatTypeGroup, chatTypeChannel:\n    // ok\ndefault:\n    return fmt.Errorf(\"unsupported chat type %q\", rctx.chatType)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always set chatType explicitly when constructing replyContext","Validate chatID prefixes against the documented formats","Handle guessChatType returning empty as an error early"],"tags":["go","tuitui","validation"],"backgroundTag":"invalid-enum-value","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}