tonhowtf/omniget · warning
[TG] diag_list_media:
Error message
[TG] diag_list_media:
What it means
Diagnostic output from the Telegram media browser: telegramDiagListMedia ran but the Telegram backend reported problems (get_history_error, per-filter search_errors, or all counts zero). The component logs the raw diag object and converts it into a user-facing mediaError string explaining the likely cause.
Solutions
- Read diag.get_history_error / diag.search_errors for the concrete Telegram API message
- If access_hash expired: leave and rejoin the chat in the official Telegram client, then retry
- If the channel is protected (saving disabled), media cannot be fetched — inform the user
- Re-authenticate the Telegram session if permission was denied
Example fix
// before
if (diag.get_history_error) {
mediaError = `Telegram negou acesso: ${diag.get_history_error}`;
}
// after
if (diag.get_history_error) {
mediaError = `Telegram negou acesso: ${diag.get_history_error}`;
console.warn("[TG] diag_list_media raw:", JSON.stringify(diag));
} Defensive patterns
Strategy: type-guard
Validate before calling
const diag = await telegramDiagListMedia({ chatId: chat.id, chatType: chat.chat_type });
if (!diag || (diag.get_history_count === 0 && diag.search_photo_count === 0 && diag.search_video_count === 0 && diag.search_document_count === 0 && !diag.get_history_error && diag.search_errors.length === 0)) return; Type guard
function hasMediaAccess(diag: TgDiag): boolean {
return !diag.get_history_error && diag.search_errors.length === 0;
} Try / catch
try {
const diag = await telegramDiagListMedia({ chatId, chatType });
if (diag.get_history_error) mediaError = `Telegram negou acesso: ${diag.get_history_error}`;
} catch (e) {
mediaError = "Falha ao consultar mídia do chat";
console.warn("[TG] diag_list_media threw:", e);
} Prevention
- Re-join chats in official Telegram when access_hash errors appear
- Detect protected channels early and skip fetching
- Keep the Telegram session authenticated and refreshed
- Surface diag fields in UI instead of only console.warn
When it happens
Trigger: Calling telegramDiagListMedia({ chatId, chatType }) returns diag with get_history_error set, non-empty search_errors, or get_history_count === 0 and all media search counts === 0.
Common situations: Channels with restricted/saved-content (protected broadcast), expired access_hash after the chat was re-joined, Telegram API permission denial for the account/session, or channels genuinely without media.
Related errors
AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12).
Data as JSON: /api/errors/dab6c602b8aa87ab.
Report an issue: GitHub.
Appendix: source
Thrown at src/lib/study-components/TelegramBrowser.svelte:1460
void preloadCachedThumbs(chat.id);
await loadMedia(true);
if (mediaItems.length === 0 && !mediaError && mediaFilter !== "all") {
console.warn(
`[TG] selectChat: 0 items com filter=${mediaFilter}, tentando filter=all`,
);
mediaFilter = "all";
await loadMedia(true);
}
if (mediaItems.length === 0 && !mediaError) {
console.warn(
`[TG] selectChat: chat="${chat.title}" tipo=${chat.chat_type} retornou 0 medias mesmo com filter=all — rodando diag`,
);
try {
const diag = await telegramDiagListMedia({
chatId: chat.id,
chatType: chat.chat_type,
});
console.warn("[TG] diag_list_media:", diag);
if (diag.get_history_error) {
mediaError = `Telegram negou acesso: ${diag.get_history_error}`;
} else if (diag.search_errors.length > 0) {
mediaError = `Telegram retornou erros nos filtros: ${diag.search_errors.join("; ")}. Possivelmente este channel é protegido (saving disabled) ou access_hash expirou. Tente sair e entrar novamente no chat pelo Telegram oficial.`;
} else if (diag.get_history_count === 0 && diag.search_photo_count === 0 && diag.search_video_count === 0 && diag.search_document_count === 0) {
mediaError = "Channel parece não ter mídia acessível via API (broadcast protegido ou content sem media). Verifique no Telegram oficial se vê os videos.";
} else if (diag.get_history_with_media === 0) {
mediaError = `Channel tem ${diag.get_history_count} mensagens mas nenhuma com mídia detectável. Verifique se as mensagens têm videos anexados (não apenas links).`;
}
} catch (e) {
console.warn("[TG] diag_list_media failed:", e);
}
}
void loadPlaybackForChat(chat.id);
}
async function preloadCachedThumbs(chatId: number) {
try {View on GitHub (pinned to 8600b91f42)