resolve comments

This commit is contained in:
duwenxin
2026-02-02 16:28:07 -05:00
committed by duwenxin99
parent ae4ceb7ba0
commit 30cef72972
5 changed files with 22 additions and 5 deletions

View File

@@ -235,11 +235,8 @@ func toolInvokeHandler(s *Server, w http.ResponseWriter, r *http.Request) {
if err != nil {
// If auth error, return 401
errMsg := fmt.Sprintf("error parsing authenticated parameters from ID token: %w", err)
if errors.Is(err, util.NewClientServerError(
errMsg,
http.StatusUnauthorized,
nil,
)) {
var clientServerErr *util.ClientServerError
if errors.As(err, &clientServerErr) && clientServerErr.Code == http.StatusUnauthorized {
s.logger.DebugContext(ctx, errMsg)
_ = render.Render(w, r, newErrResponse(err, http.StatusUnauthorized))
return
@@ -300,6 +297,11 @@ func toolInvokeHandler(s *Server, w http.ResponseWriter, r *http.Request) {
_ = render.Render(w, r, newErrResponse(err, statusCode))
return
}
} else {
// Unknown error -> 500
s.logger.ErrorContext(ctx, fmt.Sprintf("Tool invocation unknown error: %v", err))
_ = render.Render(w, r, newErrResponse(err, http.StatusInternalServerError))
return
}
}

View File

@@ -180,6 +180,7 @@ func toolsCallHandler(ctx context.Context, id jsonrpc.RequestId, resourceMgr *re
http.StatusUnauthorized,
nil,
)
return jsonrpc.NewError(id, jsonrpc.INVALID_REQUEST, err.Error(), nil), err
}
logger.DebugContext(ctx, "tool invocation authorized")
@@ -234,6 +235,9 @@ func toolsCallHandler(ctx context.Context, id jsonrpc.RequestId, resourceMgr *re
}
return jsonrpc.NewError(id, rpcCode, err.Error(), nil), err
}
} else {
// Unknown error -> 500
return jsonrpc.NewError(id, jsonrpc.INTERNAL_ERROR, err.Error(), nil), err
}
}

View File

@@ -180,6 +180,7 @@ func toolsCallHandler(ctx context.Context, id jsonrpc.RequestId, resourceMgr *re
http.StatusUnauthorized,
nil,
)
return jsonrpc.NewError(id, jsonrpc.INVALID_REQUEST, err.Error(), nil), err
}
logger.DebugContext(ctx, "tool invocation authorized")
@@ -234,6 +235,9 @@ func toolsCallHandler(ctx context.Context, id jsonrpc.RequestId, resourceMgr *re
}
return jsonrpc.NewError(id, rpcCode, err.Error(), nil), err
}
} else {
// Unknown error -> 500
return jsonrpc.NewError(id, jsonrpc.INTERNAL_ERROR, err.Error(), nil), err
}
}
content := make([]TextContent, 0)

View File

@@ -174,6 +174,7 @@ func toolsCallHandler(ctx context.Context, id jsonrpc.RequestId, resourceMgr *re
http.StatusUnauthorized,
nil,
)
return jsonrpc.NewError(id, jsonrpc.INVALID_REQUEST, err.Error(), nil), err
}
logger.DebugContext(ctx, "tool invocation authorized")
@@ -228,6 +229,9 @@ func toolsCallHandler(ctx context.Context, id jsonrpc.RequestId, resourceMgr *re
}
return jsonrpc.NewError(id, rpcCode, err.Error(), nil), err
}
} else {
// Unknown error -> 500
return jsonrpc.NewError(id, jsonrpc.INTERNAL_ERROR, err.Error(), nil), err
}
}

View File

@@ -228,6 +228,9 @@ func toolsCallHandler(ctx context.Context, id jsonrpc.RequestId, resourceMgr *re
}
return jsonrpc.NewError(id, rpcCode, err.Error(), nil), err
}
} else {
// Unknown error -> 500
return jsonrpc.NewError(id, jsonrpc.INTERNAL_ERROR, err.Error(), nil), err
}
}