Skip to content

Commit 93d6905

Browse files
committed
fix(sessions): align external id validation
1 parent 20a5fa8 commit 93d6905

6 files changed

Lines changed: 42 additions & 4 deletions

File tree

‎extensions/acpx/src/pi-session-catalog-plugin.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const MAX_HOSTS = 100;
3131
const MAX_CURSOR_LENGTH = 128;
3232
const MAX_SEARCH_LENGTH = 500;
3333
const NODE_TIMEOUT_MS = 20_000;
34-
const SESSION_ID_PATTERN = /^[A-Za-z0-9._:-]{1,256}$/u;
34+
const SESSION_ID_PATTERN = /^(?!-)[A-Za-z0-9._:-]{1,256}$/u;
3535
const TRANSCRIPT_ITEM_TYPES = new Set([
3636
"userMessage",
3737
"agentMessage",

‎extensions/acpx/src/pi-session-catalog.test.ts‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,25 @@ describe("Pi session catalog", () => {
691691
}),
692692
]);
693693

694+
invoke.mockResolvedValueOnce({
695+
payloadJSON: JSON.stringify({
696+
sessions: [
697+
{
698+
threadId: "--help",
699+
status: "stored",
700+
archived: false,
701+
canContinue: false,
702+
canArchive: false,
703+
},
704+
],
705+
}),
706+
});
707+
await expect(catalog!.list({ hostIds: ["node:node-1"] })).resolves.toEqual([
708+
expect.objectContaining({
709+
error: { code: "NODE_INVOKE_FAILED", message: expect.any(String) },
710+
}),
711+
]);
712+
694713
invoke.mockResolvedValueOnce({
695714
payloadJSON: JSON.stringify({
696715
threadId: "pi-remote",

‎extensions/acpx/src/pi-session-catalog.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const MAX_SEARCH_LENGTH = 500;
1414
const MAX_CURSOR_LENGTH = 128;
1515
const MAX_TRANSCRIPT_ITEM_BYTES = 512 * 1024;
1616
const MAX_TRANSCRIPT_PAGE_BYTES = 20 * 1024 * 1024;
17-
const SESSION_ID_PATTERN = /^[A-Za-z0-9._:-]{1,256}$/u;
17+
const SESSION_ID_PATTERN = /^(?!-)[A-Za-z0-9._:-]{1,256}$/u;
1818

1919
export type PiSessionPage = { sessions: SessionCatalogSession[]; nextCursor?: string };
2020

‎extensions/acpx/src/pi-session-store.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const MAX_SESSION_BYTES = 32 * 1024 * 1024;
1212
const MAX_SUMMARY_LINE_BYTES = 1024 * 1024;
1313
const APPEND_PROOF_EDGE_BYTES = 64 * 1024;
1414
const IO_CONCURRENCY = 8;
15-
const SESSION_ID_PATTERN = /^[A-Za-z0-9._:-]{1,256}$/u;
15+
const SESSION_ID_PATTERN = /^(?!-)[A-Za-z0-9._:-]{1,256}$/u;
1616

1717
type PiSessionSummary = SessionCatalogSession & { file: string };
1818

‎extensions/opencode/session-catalog-plugin.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const MAX_HOSTS = 100;
3232
const MAX_CURSOR_LENGTH = 128;
3333
const MAX_SEARCH_LENGTH = 500;
3434
const NODE_TIMEOUT_MS = 35_000;
35-
const SESSION_ID_PATTERN = /^[A-Za-z0-9._:-]{1,256}$/u;
35+
const SESSION_ID_PATTERN = /^(?!-)[A-Za-z0-9._:-]{1,256}$/u;
3636
const TRANSCRIPT_ITEM_TYPES = new Set([
3737
"userMessage",
3838
"agentMessage",

‎extensions/opencode/session-catalog.test.ts‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,25 @@ describe("OpenCode session catalog", () => {
321321
}),
322322
]);
323323

324+
invoke.mockResolvedValueOnce({
325+
payloadJSON: JSON.stringify({
326+
sessions: [
327+
{
328+
threadId: "--help",
329+
status: "stored",
330+
archived: false,
331+
canContinue: false,
332+
canArchive: false,
333+
},
334+
],
335+
}),
336+
});
337+
await expect(catalog!.list({ hostIds: ["node:node-1"] })).resolves.toEqual([
338+
expect.objectContaining({
339+
error: { code: "NODE_INVOKE_FAILED", message: expect.any(String) },
340+
}),
341+
]);
342+
324343
invoke.mockResolvedValueOnce({
325344
payloadJSON: JSON.stringify({
326345
threadId: "ses_remote",

0 commit comments

Comments
 (0)