{"record":{"id":"0d45ffb7466f10c7","repo":"chenhg5/cc-connect","slug":"chat-id-and-at-least-2-bots-are-required","errorCode":null,"errorMessage":"chat_id and at least 2 bots are required","messagePattern":"chat_id and at least 2 bots are required","errorType":"http","errorClass":null,"httpStatus":400,"severity":"error","filePath":"core/api.go","lineNumber":809,"sourceCode":"\t\thttp.Error(w, \"POST only\", http.StatusMethodNotAllowed)\n\t\treturn\n\t}\n\tif s.relay == nil {\n\t\thttp.Error(w, \"relay not available\", http.StatusServiceUnavailable)\n\t\treturn\n\t}\n\n\tvar req struct {\n\t\tPlatform string            `json:\"platform\"`\n\t\tChatID   string            `json:\"chat_id\"`\n\t\tBots     map[string]string `json:\"bots\"`\n\t}\n\tif err := json.NewDecoder(r.Body).Decode(&req); err != nil {\n\t\thttp.Error(w, \"invalid JSON: \"+err.Error(), http.StatusBadRequest)\n\t\treturn\n\t}\n\tif req.ChatID == \"\" || len(req.Bots) < 2 {\n\t\thttp.Error(w, \"chat_id and at least 2 bots are required\", http.StatusBadRequest)\n\t\treturn\n\t}\n\n\ts.relay.Bind(req.Platform, req.ChatID, req.Bots)\n\tapiJSON(w, http.StatusOK, map[string]string{\"status\": \"ok\"})\n}\n\nfunc (s *APIServer) handleRelayBinding(w http.ResponseWriter, r *http.Request) {\n\tif s.relay == nil {\n\t\thttp.Error(w, \"relay not available\", http.StatusServiceUnavailable)\n\t\treturn\n\t}\n\tchatID := r.URL.Query().Get(\"chat_id\")\n\tif chatID == \"\" {\n\t\thttp.Error(w, \"chat_id is required\", http.StatusBadRequest)\n\t\treturn\n\t}\n\tbinding := s.relay.GetBinding(chatID)","sourceCodeStart":791,"sourceCodeEnd":827,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/core/api.go#L791-L827","documentation":"handleRelayBind validated the bind request and rejected it: chat_id is empty or fewer than 2 bots were supplied — a relay binding is only meaningful when a chat has at least two bot identities to alternate between.","triggerScenarios":"Thrown at core/api.go:809 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Provide a non-empty chat_id and at least two entries in the bots map","Ensure each bot entry maps a bot identity to its session/key as the relay expects"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}