{"record":{"id":"52149ca827066d1d","repo":"babalae/better-genshin-impact","slug":"telegram-chat-id-is-not-set","errorCode":null,"errorMessage":"Telegram chat ID is not set","messagePattern":"Telegram chat ID is not set","errorType":"validation","errorClass":"NotifierException","httpStatus":null,"severity":"warning","filePath":"BetterGenshinImpact/Service/Notifier/TelegramNotifier.cs","lineNumber":115,"sourceCode":"                    throw new NotifierException($\"Invalid Telegram proxy URL format: {proxyUrl}. Details: {ex.Message}\");\n                }\n\n            _httpClient = new HttpClient(handler) { Timeout = TimeSpan.FromSeconds(30) };\n            _ownsHttpClient = true;\n        }\n\n        TelegramApiBaseUrl = FormatApiBaseUrl(telegramApiBaseUrl);\n    }\n\n    public void Dispose()\n    {\n        if (_ownsHttpClient) _httpClient.Dispose();\n    }\n\n    public async Task SendAsync(BaseNotificationData content)\n    {\n        if (string.IsNullOrEmpty(TelegramBotToken)) throw new NotifierException(\"Telegram bot token is not set\");\n        if (string.IsNullOrEmpty(TelegramChatId)) throw new NotifierException(\"Telegram chat ID is not set\");\n        if (string.IsNullOrEmpty(content.Message)) throw new NotifierException(\"No message content to send\");\n\n        try\n        {\n            if (content.Screenshot != null)\n            {\n                await SendImageMessageAsync(content.Screenshot, content.Message.Length < 1024 ? content.Message : null);\n                if (content.Message.Length < 1024) return;\n            }\n\n            await SendTextMessageAsync(content.Message);\n        }\n        catch (HttpRequestException ex)\n        {\n            throw new NotifierException(\"Network error sending Telegram notification: \" + ex.Message);\n        }\n        catch (TaskCanceledException)\n        {","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/Service/Notifier/TelegramNotifier.cs#L97-L133","documentation":"TelegramNotifier.SendAsync fails fast when TelegramChatId is null/empty. The chat_id is required for both sendMessage and sendPhoto; without it Telegram returns 400.","triggerScenarios":"TelegramChatId property empty at SendAsync time; line-115 IsNullOrEmpty guard fires.","commonSituations":"User configured the bot token but not the chat id; for groups, the user forgot to add the bot to the group and read the chat id; negative group id vs positive user id confusion not handled (both are strings here).","solutions":["Obtain the chat id: message the bot, then query getUpdates, or add the bot to a group and read the negative id.","Save the chat id in settings; for groups use the negative numeric id.","Validate the field is non-empty before enabling the channel."],"exampleFix":"// before\nvar n = new TelegramNotifier(null, token, chatId);\n\n// after\nif (string.IsNullOrWhiteSpace(chatId))\n    throw new InvalidOperationException(\"Telegram chat id is required (use a positive user id or negative group id).\");\nvar n = new TelegramNotifier(null, token, chatId);","handlingStrategy":"validation","validationCode":"if (string.IsNullOrWhiteSpace(chatId))\n    throw new InvalidOperationException(\"Telegram chat id is required.\");\nif (!long.TryParse(chatId.TrimStart('-'), out _))\n    throw new InvalidOperationException(\"Telegram chat id must be numeric (user id or negative group id).\");","typeGuard":"static bool IsValidTelegramChatId(string chatId)\n    => !string.IsNullOrEmpty(chatId) && long.TryParse(chatId, out _);","tryCatchPattern":"try { await telegramNotifier.SendAsync(data); }\ncatch (NotifierException ex) when (ex.Message.Contains(\"chat ID is not set\"))\n{ /* prompt user for chat id, no retry */ }","preventionTips":["Obtain the chat id by messaging the bot and calling getUpdates.","For groups use the negative numeric id.","Validate the field is set before enabling the channel."],"tags":["telegram","config","validation","notifier"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}