diff --git a/internal/sessions/handler.go b/internal/sessions/handler.go index 3cfe99a..b6f9138 100644 --- a/internal/sessions/handler.go +++ b/internal/sessions/handler.go @@ -582,8 +582,17 @@ func (h *Handler) handleSandboxCreate(w http.ResponseWriter, r *http.Request, se } // updateSandboxSummary merges pod/svc metadata into the session memory_entity (fire-and-forget). +// Uses context.Background() because r.Context() is cancelled once the HTTP handler returns. func (h *Handler) updateSandboxSummary(r *http.Request, sessionID, podName, pvcName, svcDns string) { - current, _ := h.fetchEntitySummary(r, "session-"+sessionID, sessionID, "SESSION") + // Build a detached request carrying just the auth header. + detached, _ := http.NewRequestWithContext(context.Background(), r.Method, r.URL.String(), nil) + if auth := r.Header.Get("Authorization"); auth != "" { + detached.Header.Set("Authorization", auth) + } + current, _ := h.fetchEntitySummary(detached, "session-"+sessionID, sessionID, "SESSION") + if current == nil { + current = map[string]any{} + } current["pod_name"] = podName current["svc_dns"] = svcDns current["last_active_at"] = time.Now().UTC().Format(time.RFC3339)