From 46acd1c01bc6cc4556cce67145fdc8685b4bce53 Mon Sep 17 00:00:00 2001 From: octo-patch Date: Mon, 20 Apr 2026 09:43:06 +0800 Subject: [PATCH 1/2] fix: accept Claude session keys in sk-ant-sid02 format (fixes #935) Anthropic now issues session keys with the prefix sk-ant-sid02- in addition to the previous sk-ant-sid01- format. The validation was too strict, rejecting valid new-format keys with an error. Relaxed the check to match any sk-ant-sid prefix to be forward-compatible with future key format versions. --- src/services/clients/claude/index.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/services/clients/claude/index.mjs b/src/services/clients/claude/index.mjs index c026f710..b20a487b 100644 --- a/src/services/clients/claude/index.mjs +++ b/src/services/clients/claude/index.mjs @@ -74,8 +74,8 @@ export class Claude { if (!sessionKey) { throw new Error('Session key required') } - if (!sessionKey.startsWith('sk-ant-sid01')) { - throw new Error('Session key invalid: Must be in the format sk-ant-sid01-*****') + if (!sessionKey.startsWith('sk-ant-sid')) { + throw new Error('Session key invalid: Must be in the format sk-ant-sid01-***** or sk-ant-sid02-*****') } if (fetch) { this.fetch = fetch From ee16c1e2ab78d5a18cae4dd20383ee83e923e7f9 Mon Sep 17 00:00:00 2001 From: octo-patch Date: Mon, 20 Apr 2026 13:10:09 +0800 Subject: [PATCH 2/2] fix(claude): require version digits in session key prefix Tightens the session key validation to match the documented format more closely. The previous `startsWith('sk-ant-sid')` accepted malformed values like `sk-ant-sidney` or `sk-ant-sid02` (missing the trailing `-`), which would later fail authentication with a confusing 'login first' message. Now uses /^sk-ant-sid\d+-/ which: - accepts existing sid01/sid02 keys - accepts future sidNN versions (forward compatible) - rejects malformed keys at construction time Error message updated to reflect the generalised format while still showing the known examples. Addresses review feedback from CodeRabbit, Qodo and gemini-code-assist. --- src/services/clients/claude/index.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/services/clients/claude/index.mjs b/src/services/clients/claude/index.mjs index b20a487b..398e0226 100644 --- a/src/services/clients/claude/index.mjs +++ b/src/services/clients/claude/index.mjs @@ -74,8 +74,8 @@ export class Claude { if (!sessionKey) { throw new Error('Session key required') } - if (!sessionKey.startsWith('sk-ant-sid')) { - throw new Error('Session key invalid: Must be in the format sk-ant-sid01-***** or sk-ant-sid02-*****') + if (!/^sk-ant-sid\d+-/.test(sessionKey)) { + throw new Error('Session key invalid: Must be in the format sk-ant-sidNN-***** (e.g. sk-ant-sid01-*****, sk-ant-sid02-*****)') } if (fetch) { this.fetch = fetch