Skip to content

Commit df0dc31

Browse files
committed
fix: nullable json-rpc error id instead of optional
1 parent 06a4fd2 commit df0dc31

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/server/streamableHttp.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -873,7 +873,7 @@ export class StreamableHTTPServerTransport implements Transport {
873873
let requestId = options?.relatedRequestId;
874874
if (isJSONRPCResultResponse(message) || isJSONRPCErrorResponse(message)) {
875875
// If the message is a response, use the request ID from the message
876-
requestId = message.id;
876+
requestId = message.id ?? undefined;
877877
}
878878

879879
// Check if this message should be sent on the standalone SSE stream (no request ID)

src/spec.types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ export interface JSONRPCResultResponse {
169169
*/
170170
export interface JSONRPCErrorResponse {
171171
jsonrpc: typeof JSONRPC_VERSION;
172-
id?: RequestId;
172+
id: RequestId | null;
173173
error: Error;
174174
}
175175

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ export enum ErrorCode {
198198
export const JSONRPCErrorResponseSchema = z
199199
.object({
200200
jsonrpc: z.literal(JSONRPC_VERSION),
201-
id: RequestIdSchema.optional(),
201+
id: RequestIdSchema.nullable(),
202202
error: z.object({
203203
/**
204204
* The error type that occurred.

0 commit comments

Comments
 (0)