test(telegram): cover getFile file-too-big errors

This commit is contained in:
Sebastian
2026-02-16 22:10:59 -05:00
parent d137f33281
commit 78c3e5166b
2 changed files with 18 additions and 0 deletions

View File

@@ -42,7 +42,9 @@ Docs: https://docs.openclaw.ai
- Telegram: disable block streaming when `channels.telegram.streamMode` is `off`, preventing newline/content-block replies from splitting into multiple messages. (#17679) Thanks @saivarunk.
- Telegram: route non-abort slash commands on the normal chat/topic sequential lane while keeping true abort requests (`/stop`, `stop`) on the control lane, preventing command/reply race conditions from control-lane bypass. (#17899) Thanks @obviyus.
- Telegram: ignore `<media:...>` placeholder lines when extracting `MEDIA:` tool-result paths, preventing false local-file reads and dropped replies. (#18510) Thanks @yinghaosang.
- Telegram: skip retries when inbound media `getFile` fails with Telegram's 20MB limit and continue processing message text, avoiding dropped messages for oversized attachments. (#18531) Thanks @brandonwise.
- Auto-reply/TTS: keep tool-result media delivery enabled in group chats and native command sessions (while still suppressing tool summary text) so `NO_REPLY` follow-ups do not drop successful TTS audio. (#17991) Thanks @zerone0x.
- Agents/Tools: deliver tool-result media even when verbose tool output is off so media attachments are not dropped. (#16679)
- Discord: optimize reaction notification handling to skip unnecessary message fetches in `off`/`all`/`allowlist` modes, streamline reaction routing, and improve reaction emoji formatting. (#18248) Thanks @thewilloftheshadow and @victorGPT.
- CLI/Pairing: make `openclaw qr --remote` prefer `gateway.remote.url` over tailscale/public URL resolution and register the `openclaw clawbot qr` legacy alias path. (#18091)
- CLI/QR: restore fail-fast validation for `openclaw qr --remote` when neither `gateway.remote.url` nor tailscale `serve`/`funnel` is configured, preventing unusable remote pairing QR flows. (#18166) Thanks @mbelinky.

View File

@@ -1,4 +1,5 @@
import type { Message } from "@grammyjs/types";
import { GrammyError } from "grammy";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import type { TelegramContext } from "./types.js";
@@ -150,6 +151,21 @@ describe("resolveMedia getFile retry", () => {
expect(result).toBeNull();
});
it("does not retry 'file is too big' GrammyError instances and returns null", async () => {
const fileTooBigError = new GrammyError(
"Call to 'getFile' failed!",
{ error_code: 400, description: "Bad Request: file is too big" },
"getFile",
{},
);
const getFile = vi.fn().mockRejectedValue(fileTooBigError);
const result = await resolveMedia(makeCtx("video", getFile), 10_000_000, "tok123");
expect(getFile).toHaveBeenCalledTimes(1);
expect(result).toBeNull();
});
it("returns null for audio when file is too big", async () => {
const fileTooBigError = new Error(
"GrammyError: Call to 'getFile' failed! (400: Bad Request: file is too big)",