mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-26 20:35:39 -06:00
fix(mcp-grant): guard sessionKey.trim() against undefined input (#99488)
The mintAttachGrant caller resolves sessionKey via readString() ?? resolveMainSessionKey(). If both return undefined, .trim() throws TypeError. Use optional chaining + nullish coalescing so the existing if (!sessionKey) validation guard executes instead of crashing.
This commit is contained in:
@@ -28,7 +28,7 @@ export function mintAttachGrant(params: {
|
||||
ttlMs?: number;
|
||||
nowMs?: number;
|
||||
}): McpAttachGrant {
|
||||
const sessionKey = params.sessionKey.trim();
|
||||
const sessionKey = params.sessionKey?.trim() ?? "";
|
||||
if (!sessionKey) {
|
||||
throw new Error("mintAttachGrant: sessionKey is required");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user