惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
MyScale Blog
MyScale Blog
U
Unit 42
M
MIT News - Artificial intelligence
小众软件
小众软件
P
Proofpoint News Feed
雷峰网
雷峰网
L
LangChain Blog
S
SegmentFault 最新的问题
腾讯CDC
F
Fortinet All Blogs
A
About on SuperTechFans
WordPress大学
WordPress大学
Vercel News
Vercel News
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
G
Google Developers Blog
大猫的无限游戏
大猫的无限游戏
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
D
Docker
N
Netflix TechBlog - Medium
Apple Machine Learning Research
Apple Machine Learning Research
Recent Announcements
Recent Announcements
D
DataBreaches.Net
Stack Overflow Blog
Stack Overflow Blog

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(telegram): ignore unsafe cached message ids · opencla...
steipete · 2026-05-29 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -405,6 +405,30 @@ describe("telegram message cache", () => {

405405

expect(recent.map((entry) => entry.messageId)).toEqual(["9122", "9123", "9124"]);

406406

});

407407
408+

it("does not use unsafe message ids as recent-before cutoffs", async () => {

409+

const cache = createTelegramMessageCache();

410+

await cache.record({

411+

accountId: "default",

412+

chatId: 7,

413+

msg: {

414+

chat: { id: 7, type: "private", first_name: "Nora" },

415+

message_id: 9124,

416+

date: 1736380700,

417+

text: "State message",

418+

from: { id: 1, is_bot: false, first_name: "Nora" },

419+

} as Message,

420+

});

421+
422+

const recent = await cache.recentBefore({

423+

accountId: "default",

424+

chatId: 7,

425+

messageId: "9007199254740992",

426+

limit: 10,

427+

});

428+
429+

expect(recent).toEqual([]);

430+

});

431+
408432

it("reads legacy sidecar records as a persistent-store fallback", async () => {

409433

const storePath = `/tmp/openclaw-telegram-message-cache-state-migrate-${process.pid}-${Date.now()}.json`;

410434

const persistedPath = resolveTelegramMessageCachePath(storePath);

Original file line numberDiff line numberDiff line change

@@ -2,6 +2,7 @@ import { createHash } from "node:crypto";

22

import fs from "node:fs";

33

import type { Message } from "grammy/types";

44

import { formatLocationText } from "openclaw/plugin-sdk/channel-inbound";

5+

import { parseStrictPositiveInteger } from "openclaw/plugin-sdk/number-runtime";

56

import type { MsgContext } from "openclaw/plugin-sdk/reply-runtime";

67

import { logVerbose } from "openclaw/plugin-sdk/runtime-env";

78

import { appendRegularFileSync, replaceFileAtomicSync } from "openclaw/plugin-sdk/security-runtime";

@@ -240,6 +241,10 @@ function readOptionalString(record: Record<string, unknown>, key: string): strin

240241

return isString(value) ? value : undefined;

241242

}

242243
244+

function parseSafeMessageId(value: string | undefined): number | undefined {

245+

return value === undefined ? undefined : parseStrictPositiveInteger(value);

246+

}

247+
243248

function isTelegramSourceMessage(value: unknown): value is Message {

244249

return (

245250

isRecord(value) &&

@@ -788,14 +793,14 @@ export function createTelegramMessageCache(params?: {

788793

if (!messageId || limit <= 0) {

789794

return [];

790795

}

791-

const targetId = Number(messageId);

792-

if (!Number.isFinite(targetId)) {

796+

const targetId = parseSafeMessageId(messageId);

797+

if (targetId === undefined) {

793798

return [];

794799

}

795800

return (await listChatMessages({ accountId, chatId, threadId }))

796801

.filter((entry) => {

797-

const entryId = Number(entry.messageId);

798-

return Number.isFinite(entryId) && entryId < targetId;

802+

const entryId = parseSafeMessageId(entry.messageId);

803+

return entryId !== undefined && entryId < targetId;

799804

})

800805

.slice(-limit);

801806

},

@@ -820,9 +825,9 @@ function compareCachedMessageNodes(

820825

left: TelegramCachedMessageNode,

821826

right: TelegramCachedMessageNode,

822827

) {

823-

const leftId = Number(left.messageId);

824-

const rightId = Number(right.messageId);

825-

if (Number.isFinite(leftId) && Number.isFinite(rightId)) {

828+

const leftId = parseSafeMessageId(left.messageId);

829+

const rightId = parseSafeMessageId(right.messageId);

830+

if (leftId !== undefined && rightId !== undefined) {

826831

return leftId - rightId;

827832

}

828833

return (left.messageId ?? "").localeCompare(right.messageId ?? "");

@@ -845,9 +850,9 @@ function isAfterSessionBoundary(

845850

if (!boundary) {

846851

return true;

847852

}

848-

const nodeId = Number(node.messageId);

849-

const boundaryId = Number(boundary.messageId);

850-

if (Number.isFinite(nodeId) && Number.isFinite(boundaryId)) {

853+

const nodeId = parseSafeMessageId(node.messageId);

854+

const boundaryId = parseSafeMessageId(boundary.messageId);

855+

if (nodeId !== undefined && boundaryId !== undefined) {

851856

return nodeId > boundaryId;

852857

}

853858

if (