{"record":{"id":"044005eb81e55713","repo":"Tencent/WeKnora","slug":"unsupported-dingtalk-mode-s","errorCode":null,"errorMessage":"unsupported dingtalk mode: %s","messagePattern":"unsupported dingtalk mode: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/im/dingtalk/factory.go","lineNumber":48,"sourceCode":"\t\tcase \"websocket\":\n\t\t\twsCtx, wsCancel := context.WithCancel(context.Background())\n\t\t\tgo im.RunSupervised(wsCtx, im.SupervisorConfig{\n\t\t\t\tName: fmt.Sprintf(\"DingTalk channel %s\", channel.ID),\n\t\t\t\tConnect: func(ctx context.Context) (func(), error) {\n\t\t\t\t\tclient := NewLongConnClient(clientID, clientSecret, msgHandler)\n\t\t\t\t\tif err := client.Start(ctx); err != nil {\n\t\t\t\t\t\tclient.Close()\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t\treturn client.Close, nil\n\t\t\t\t},\n\t\t\t})\n\n\t\t\tadapter := NewAdapter(clientID, clientSecret, cardTemplateID)\n\t\t\treturn adapter, wsCancel, nil\n\n\t\tdefault:\n\t\t\treturn nil, nil, fmt.Errorf(\"unsupported dingtalk mode: %s\", mode)\n\t\t}\n\t}\n}\n","sourceCodeStart":30,"sourceCodeEnd":52,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/im/dingtalk/factory.go#L30-L52","documentation":"The DingTalk factory supports two modes: \"webhook\" and \"websocket\" (the default via stream mode). Any other value for the mode credential/setting hits the default branch and returns this error naming the unsupported mode string.","triggerScenarios":"Configuring a DingTalk IM channel with mode set to something other than \"webhook\" or \"websocket\" (e.g. \"stream\", \"ws\", \"Webhook\" with wrong casing).","commonSituations":"Copy-pasting mode values from docs for other IM providers; typo or casing differences; older config using a mode name that was never supported.","solutions":["Set mode to exactly \"websocket\" (recommended, stream mode) or \"webhook\".","Remove the mode field entirely if you want the default (websocket) behavior.","Check casing — values are matched case-sensitively, so \"Webhook\" will fail."],"exampleFix":"// before\n\"mode\": \"stream\"\n// after\n\"mode\": \"websocket\"","handlingStrategy":"validation","validationCode":"allowed := map[string]bool{\"webhook\": true, \"websocket\": true, \"\": true}\nif !allowed[mode] {\n    return fmt.Errorf(\"dingtalk mode must be \\\"webhook\\\" or \\\"websocket\\\", got %q\", mode)\n}","typeGuard":"func validDingTalkMode(m string) bool { return m == \"\" || m == \"webhook\" || m == \"websocket\" }","tryCatchPattern":"adapter, cancel, err := factory(ctx, channel, handler)\nif err != nil {\n    if strings.HasPrefix(err.Error(), \"unsupported dingtalk mode\") {\n        return fmt.Errorf(\"set mode to \\\"websocket\\\" (default) or \\\"webhook\\\"\")\n    }\n    return err\n}","preventionTips":["Only use documented mode values: webhook, websocket.","Omit the mode field to get the websocket default.","Watch for casing and whitespace when mode comes from env or config."],"tags":["config","dingtalk","unsupported-value"],"backgroundTag":"unsupported-config-value","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}