sunchao commented on code in PR #57219:
URL: https://github.com/apache/spark/pull/57219#discussion_r3641734449


##########
sql/connect/server/src/main/scala/org/apache/spark/status/api/v1/connect/ConnectResource.scala:
##########
@@ -37,12 +37,27 @@ private[v1] class ConnectResource extends BaseAppResource {
     sessions.map(prepareSessionData)
   }
 
+  // A session is identified by the composite (userId, sessionId): two users 
may share the same
+  // session UUID, so userId is required to resolve exactly one session. 
userId is an opaque
+  // identifier passed as a base64url token so it survives the UI request 
sanitization intact.
   @GET
   @Path("sessions/{sessionId}")
-  def session(@PathParam("sessionId") sessionId: String): SessionData = withUI 
{ ui =>
+  def session(
+      @PathParam("sessionId") sessionId: String,
+      @QueryParam("userId") userId: String): SessionData = withUI { ui =>
+    if (userId == null || userId.isEmpty) {

Review Comment:
   [P2] Keep empty Connect user IDs addressable
   
   The base64url encoding of the empty user ID is itself empty, but this check 
treats `?userId=` as missing. Spark Connect accepts an empty `user_id`: it is 
the protobuf default, PySpark omits the field when its user ID is unset or 
empty, and session creation validates only the session UUID. Those sessions are 
stored and returned by `/sessions`, yet `/sessions/{id}?userId=` always returns 
400, so their detail endpoint can no longer be resolved. Please distinguish an 
absent parameter from a present empty token (or otherwise give the empty user a 
non-empty representation) and add coverage.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to