@@ -8,14 +8,15 @@ import (
88 "path/filepath"
99 "time"
1010
11+ "github.com/github/gh-aw-mcpg/internal/auth"
1112 "github.com/github/gh-aw-mcpg/internal/logger"
1213)
1314
1415var logSession = logger .New ("server:session" )
1516
1617// NewSession creates a new Session with the given session ID and optional token
1718func NewSession (sessionID , token string ) * Session {
18- logSession .Printf ("Creating new session: sessionID=%s, has_token=%v" , sessionID , token != "" )
19+ logSession .Printf ("Creating new session: sessionID=%s, has_token=%v" , auth . TruncateSessionID ( sessionID ) , token != "" )
1920 return & Session {
2021 Token : token ,
2122 SessionID : sessionID ,
@@ -27,8 +28,8 @@ func NewSession(sessionID, token string) *Session {
2728// getSessionID extracts the MCP session ID from the context
2829func (us * UnifiedServer ) getSessionID (ctx context.Context ) string {
2930 if sessionID , ok := ctx .Value (SessionIDContextKey ).(string ); ok && sessionID != "" {
30- logSession .Printf ("Extracted session ID from context: %s" , sessionID )
31- log .Printf ("Extracted session ID from context: %s" , sessionID )
31+ logSession .Printf ("Extracted session ID from context: %s" , auth . TruncateSessionID ( sessionID ) )
32+ log .Printf ("Extracted session ID from context: %s" , auth . TruncateSessionID ( sessionID ) )
3233 return sessionID
3334 }
3435 // No session ID in context - this happens before the SDK assigns one
@@ -58,16 +59,16 @@ func (us *UnifiedServer) ensureSessionDirectory(sessionID string) error {
5859 }
5960
6061 logUnified .Printf ("Created session directory: %s" , sessionDir )
61- log .Printf ("Created payload directory for session: %s" , sessionID )
62+ log .Printf ("Created payload directory for session: %s" , auth . TruncateSessionID ( sessionID ) )
6263 return nil
6364}
6465
6566// requireSession checks that a session has been initialized for this request
6667// Sessions are automatically created if one doesn't exist (for standard MCP client compatibility)
6768func (us * UnifiedServer ) requireSession (ctx context.Context ) error {
6869 sessionID := us .getSessionID (ctx )
69- logSession .Printf ("Checking session: sessionID=%s" , sessionID )
70- log .Printf ("Checking session for ID: %s" , sessionID )
70+ logSession .Printf ("Checking session: sessionID=%s" , auth . TruncateSessionID ( sessionID ) )
71+ log .Printf ("Checking session for ID: %s" , auth . TruncateSessionID ( sessionID ) )
7172
7273 // Use double-checked locking to auto-create session if needed
7374 us .sessionMu .RLock ()
@@ -79,23 +80,23 @@ func (us *UnifiedServer) requireSession(ctx context.Context) error {
7980 us .sessionMu .Lock ()
8081 // Double-check after acquiring write lock to avoid race condition
8182 if us .sessions [sessionID ] == nil {
82- log .Printf ("Auto-creating session for ID: %s" , sessionID )
83+ log .Printf ("Auto-creating session for ID: %s" , auth . TruncateSessionID ( sessionID ) )
8384 us .sessions [sessionID ] = NewSession (sessionID , "" )
84- log .Printf ("Session auto-created for ID: %s" , sessionID )
85+ log .Printf ("Session auto-created for ID: %s" , auth . TruncateSessionID ( sessionID ) )
8586
8687 // Ensure session directory exists in payload mount point
8788 // This is done after releasing the lock to avoid holding it during I/O
8889 us .sessionMu .Unlock ()
8990 if err := us .ensureSessionDirectory (sessionID ); err != nil {
90- logger .LogWarn ("client" , "Failed to create session directory for session=%s: %v" , sessionID , err )
91+ logger .LogWarn ("client" , "Failed to create session directory for session=%s: %v" , auth . TruncateSessionID ( sessionID ) , err )
9192 // Don't fail - payloads will attempt to create the directory when needed
9293 }
9394 return nil
9495 }
9596 us .sessionMu .Unlock ()
9697 }
9798
98- log .Printf ("Session validated for ID: %s" , sessionID )
99+ log .Printf ("Session validated for ID: %s" , auth . TruncateSessionID ( sessionID ) )
99100 return nil
100101}
101102
0 commit comments