@@ -312,7 +312,17 @@ func (h *WebSocketHandler) validateAuth(ctx context.Context, ws *websocket.Conn,
312312 errorReason = "forbidden"
313313 case strings .Contains (errStr , "not a member" ):
314314 errorCode = "access_denied"
315- errorMsg = fmt .Sprintf ("You are not a member of organization '%s'." , sub .Organization )
315+ // Include username/app identifier in error message
316+ if username != "" {
317+ if len (userOrgs ) > 0 {
318+ errorMsg = fmt .Sprintf ("User '%s' is not a member of organization '%s'. Member of: %s" ,
319+ username , sub .Organization , strings .Join (userOrgs , ", " ))
320+ } else {
321+ errorMsg = fmt .Sprintf ("User '%s' is not a member of organization '%s'." , username , sub .Organization )
322+ }
323+ } else {
324+ errorMsg = fmt .Sprintf ("You are not a member of organization '%s'." , sub .Organization )
325+ }
316326 errorReason = "not_org_member"
317327 case strings .Contains (errStr , "rate limit" ):
318328 errorCode = "rate_limit_exceeded"
@@ -325,6 +335,7 @@ func (h *WebSocketHandler) validateAuth(ctx context.Context, ws *websocket.Conn,
325335 logger .Error ("GitHub auth/org membership validation failed" , err , logger.Fields {
326336 "ip" : ip ,
327337 "org" : sub .Organization ,
338+ "username" : username ,
328339 "token_prefix" : tokenPrefix ,
329340 "token_length" : len (githubToken ),
330341 "reason" : errorReason ,
0 commit comments