Sessions: canonicalize mixed-case session keys

This commit is contained in:
Vignesh Natarajan
2026-02-22 23:26:32 -08:00
parent 1be8897339
commit 9ea740afb6
5 changed files with 229 additions and 15 deletions

View File

@@ -75,4 +75,32 @@ describe("recordInboundSession", () => {
}),
);
});
it("normalizes mixed-case session keys before recording and route updates", async () => {
const { recordInboundSession } = await import("./session.js");
await recordInboundSession({
storePath: "/tmp/openclaw-session-store.json",
sessionKey: "Agent:Main:Telegram:1234:Thread:42",
ctx,
updateLastRoute: {
sessionKey: "agent:main:telegram:1234:thread:42",
channel: "telegram",
to: "telegram:1234",
},
onRecordError: vi.fn(),
});
expect(recordSessionMetaFromInboundMock).toHaveBeenCalledWith(
expect.objectContaining({
sessionKey: "agent:main:telegram:1234:thread:42",
}),
);
expect(updateLastRouteMock).toHaveBeenCalledWith(
expect.objectContaining({
sessionKey: "agent:main:telegram:1234:thread:42",
ctx,
}),
);
});
});