mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 08:20:43 +00:00
fix(telegram): tighten permanent edit error match
This commit is contained in:
committed by
Peter Steinberger
parent
d8b18f1d96
commit
90b8f3fba2
@@ -675,7 +675,7 @@ export const registerTelegramHandlers = ({
|
||||
}
|
||||
|
||||
const TELEGRAM_PERMANENT_CALLBACK_EDIT_ERROR_RE =
|
||||
/400:\s*Bad Request:\s*message to edit not found|400:\s*Bad Request:\s*there is no text in the message to edit|MESSAGE_ID_INVALID|message can't be edited/i;
|
||||
/400:\s*Bad Request:\s*message to edit not found|400:\s*Bad Request:\s*there is no text in the message to edit|MESSAGE_ID_INVALID|400:\s*Bad Request:\s*message can't be edited/i;
|
||||
|
||||
const isPermanentTelegramCallbackEditError = (err: unknown): boolean =>
|
||||
TELEGRAM_PERMANENT_CALLBACK_EDIT_ERROR_RE.test(String(err));
|
||||
|
||||
@@ -3384,6 +3384,43 @@ describe("createTelegramBot", () => {
|
||||
expect(editMessageTextSpy).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("does not swallow unprefixed command pagination edit failures", async () => {
|
||||
createTelegramBot({ token: "tok" });
|
||||
const callbackHandler = getOnHandler("callback_query");
|
||||
|
||||
const ctx = {
|
||||
update: { update_id: 778 },
|
||||
callbackQuery: {
|
||||
id: "cbq-commands-non-telegram-edit-1",
|
||||
data: "commands_page_2:main",
|
||||
from: { id: 9, first_name: "Ada", username: "ada_bot" },
|
||||
message: {
|
||||
chat: { id: 1234, type: "private" },
|
||||
date: 1736380800,
|
||||
message_id: 21,
|
||||
},
|
||||
},
|
||||
me: { username: "openclaw_bot" },
|
||||
getFile: async () => ({ download: async () => new Uint8Array() }),
|
||||
};
|
||||
|
||||
editMessageTextSpy.mockRejectedValueOnce(new Error("message can't be edited"));
|
||||
|
||||
await expect(
|
||||
runTelegramMiddlewareChain({
|
||||
ctx,
|
||||
finalHandler: callbackHandler,
|
||||
}),
|
||||
).rejects.toThrow("message can't be edited");
|
||||
|
||||
await runTelegramMiddlewareChain({
|
||||
ctx,
|
||||
finalHandler: callbackHandler,
|
||||
});
|
||||
|
||||
expect(editMessageTextSpy).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it("retries command pagination callbacks after a bubbled preflight failure", async () => {
|
||||
const listSkillCommandsMock = listSkillCommandsForAgents as unknown as ReturnType<typeof vi.fn>;
|
||||
listSkillCommandsMock.mockClear();
|
||||
|
||||
Reference in New Issue
Block a user