From cc895636b34965574940b0e3df9ca31410e1ab18 Mon Sep 17 00:00:00 2001 From: Aidan Daly Date: Thu, 3 Sep 2026 16:41:42 +0000 Subject: [PATCH 1/3] fix(runtime): default omitted invoke user ID --- src/handlers/runtime/invoke/invoke.screen.test.tsx | 2 +- src/handlers/runtime/invoke/invoke.test.tsx | 1 + src/handlers/runtime/invoke/request.test.ts | 9 +++++++++ src/handlers/runtime/invoke/request.ts | 2 ++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/handlers/runtime/invoke/invoke.screen.test.tsx b/src/handlers/runtime/invoke/invoke.screen.test.tsx index c8a3781f5..a642a84e8 100644 --- a/src/handlers/runtime/invoke/invoke.screen.test.tsx +++ b/src/handlers/runtime/invoke/invoke.screen.test.tsx @@ -808,7 +808,7 @@ describe("Runtime invoke JSON console", () => { await screen.write("{}"); await screen.press("return"); await waitFor(() => invokeRequests(core).length === 1); - expect(invokeRequests(core)[0]!.runtimeUserId).toBeUndefined(); + expect(invokeRequests(core)[0]!.runtimeUserId).toBe("default"); expect(invokeRequests(core)[0]!.applicationHeaders).toBeUndefined(); expect(invokeRequests(core)[0]!.bearerToken).toBeUndefined(); }); diff --git a/src/handlers/runtime/invoke/invoke.test.tsx b/src/handlers/runtime/invoke/invoke.test.tsx index 2d732d097..d2b22ef7b 100644 --- a/src/handlers/runtime/invoke/invoke.test.tsx +++ b/src/handlers/runtime/invoke/invoke.test.tsx @@ -106,6 +106,7 @@ describe("runtime invoke", () => { qualifier: "DEFAULT", payload: new TextEncoder().encode('{"prompt":"hello"}'), contentType: "application/json", + runtimeUserId: "default", }); expect(invoke.args[1]).toEqual({ region: REGION }); expect(lookup.args[2]).toBe(invoke.args[2]); diff --git a/src/handlers/runtime/invoke/request.test.ts b/src/handlers/runtime/invoke/request.test.ts index 4b6625a7c..f1db5b8d8 100644 --- a/src/handlers/runtime/invoke/request.test.ts +++ b/src/handlers/runtime/invoke/request.test.ts @@ -212,6 +212,15 @@ describe("normalizeRuntimeInvokeRequest", () => { expect(request.accept).toBe("application/json, text/event-stream"); }); + test("defaults the Runtime user ID when omitted", () => { + const request = normalizeRuntimeInvokeRequest(detail(), { + runtimeId: RUNTIME_ID, + payload: new Uint8Array(), + }); + + expect(request.runtimeUserId).toBe("default"); + }); + test("maps every request field and ordered allowed headers once", () => { const request = normalizeRuntimeInvokeRequest( detail({ diff --git a/src/handlers/runtime/invoke/request.ts b/src/handlers/runtime/invoke/request.ts index 1633321a7..d5400a9f3 100644 --- a/src/handlers/runtime/invoke/request.ts +++ b/src/handlers/runtime/invoke/request.ts @@ -15,6 +15,7 @@ export type RuntimeInvokeInput = Omit< > & Partial>; +const DEFAULT_RUNTIME_USER_ID = "default"; const CUSTOM_HEADER_PREFIX = "x-amzn-bedrock-agentcore-runtime-custom-"; const RESERVED_HEADERS = new Set([ "authorization", @@ -170,6 +171,7 @@ export function normalizeRuntimeInvokeRequest( payload, contentType: contentType || "application/json", ...modeled, + runtimeUserId: modeled.runtimeUserId ?? DEFAULT_RUNTIME_USER_ID, accept: modeled.accept ?? (mcp ? "application/json, text/event-stream" : undefined), ...(applicationHeaders.length > 0 && { applicationHeaders }), }; From 7e329e866dac34c7e83e0f96745d4ad81497528c Mon Sep 17 00:00:00 2001 From: Aidan Daly Date: Thu, 3 Sep 2026 16:42:11 +0000 Subject: [PATCH 2/3] test(project): cover default Runtime invoke user ID --- src/handlers/project/invoke/index.test.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/handlers/project/invoke/index.test.tsx b/src/handlers/project/invoke/index.test.tsx index 91ce9dd4f..679bd1f94 100644 --- a/src/handlers/project/invoke/index.test.tsx +++ b/src/handlers/project/invoke/index.test.tsx @@ -162,6 +162,7 @@ describe("project invoke", () => { .args[0] as RuntimeInvokeRequest; expect(new TextDecoder().decode(request.payload)).toBe(payload); expect(request.contentType).toBe("application/custom+json"); + expect(request.runtimeUserId).toBe("default"); expect(core.runtime.calls.at(-1)!.args[1]).toEqual({ region: TARGET.region }); expect(io.stdout()).toBe("runtime response"); expect(resolved.calls).toEqual([{ target: TARGET }]); From 279104882228ccc8e1c4bd194ac4d4325fb30868 Mon Sep 17 00:00:00 2001 From: Aidan Daly Date: Thu, 3 Sep 2026 16:42:58 +0000 Subject: [PATCH 3/3] docs(invoke): document default Runtime user ID --- src/handlers/project/invoke/runtime.tsx | 2 +- src/handlers/runtime/invoke/index.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/handlers/project/invoke/runtime.tsx b/src/handlers/project/invoke/runtime.tsx index a5dcaab05..4e8de96af 100644 --- a/src/handlers/project/invoke/runtime.tsx +++ b/src/handlers/project/invoke/runtime.tsx @@ -33,7 +33,7 @@ export const createProjectInvokeRuntimeHandler = ( flag("content-type", "the payload content type", z.string().optional()), flag("accept", "the accepted response content type", z.string().optional()), flag("session-id", "the Runtime session ID", z.string().optional()), - flag("user-id", "the Runtime user ID", z.string().optional()), + flag("user-id", 'the Runtime user ID (default: "default")', z.string().optional()), flag("header", "an ordered application header", z.array(z.string()).optional(), { sensitive: true, }), diff --git a/src/handlers/runtime/invoke/index.tsx b/src/handlers/runtime/invoke/index.tsx index 147b476ea..96d8b1566 100644 --- a/src/handlers/runtime/invoke/index.tsx +++ b/src/handlers/runtime/invoke/index.tsx @@ -30,7 +30,7 @@ export const createInvokeRuntimeHandler = (core: Core, io: AppIO) => flag("content-type", "the payload content type", z.string().optional()), flag("accept", "the accepted response content type", z.string().optional()), flag("session-id", "the Runtime session ID", z.string().optional()), - flag("user-id", "the Runtime user ID", z.string().optional()), + flag("user-id", 'the Runtime user ID (default: "default")', z.string().optional()), flag("header", "an ordered application header", z.array(z.string()).optional(), { sensitive: true, }),