Fix context background and silent JWT
This commit is contained in:
@@ -51,7 +51,7 @@ func (s *GatewayServer) handleReady(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
// Test conversation store by attempting a simple operation
|
||||
testID := "health_check_test"
|
||||
_, err := s.convs.Get(testID)
|
||||
_, err := s.convs.Get(ctx, testID)
|
||||
if err != nil {
|
||||
checks["conversation_store"] = "unhealthy: " + err.Error()
|
||||
allHealthy = false
|
||||
|
||||
@@ -156,7 +156,7 @@ func newMockConversationStore() *mockConversationStore {
|
||||
}
|
||||
}
|
||||
|
||||
func (m *mockConversationStore) Get(id string) (*conversation.Conversation, error) {
|
||||
func (m *mockConversationStore) Get(ctx context.Context, id string) (*conversation.Conversation, error) {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
|
||||
@@ -170,7 +170,7 @@ func (m *mockConversationStore) Get(id string) (*conversation.Conversation, erro
|
||||
return conv, nil
|
||||
}
|
||||
|
||||
func (m *mockConversationStore) Create(id string, model string, messages []api.Message) (*conversation.Conversation, error) {
|
||||
func (m *mockConversationStore) Create(ctx context.Context, id string, model string, messages []api.Message) (*conversation.Conversation, error) {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
|
||||
@@ -187,7 +187,7 @@ func (m *mockConversationStore) Create(id string, model string, messages []api.M
|
||||
return conv, nil
|
||||
}
|
||||
|
||||
func (m *mockConversationStore) Append(id string, messages ...api.Message) (*conversation.Conversation, error) {
|
||||
func (m *mockConversationStore) Append(ctx context.Context, id string, messages ...api.Message) (*conversation.Conversation, error) {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
|
||||
@@ -203,7 +203,7 @@ func (m *mockConversationStore) Append(id string, messages ...api.Message) (*con
|
||||
return conv, nil
|
||||
}
|
||||
|
||||
func (m *mockConversationStore) Delete(id string) error {
|
||||
func (m *mockConversationStore) Delete(ctx context.Context, id string) error {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ func (s *GatewayServer) handleResponses(w http.ResponseWriter, r *http.Request)
|
||||
// Build full message history from previous conversation
|
||||
var historyMsgs []api.Message
|
||||
if req.PreviousResponseID != nil && *req.PreviousResponseID != "" {
|
||||
conv, err := s.convs.Get(*req.PreviousResponseID)
|
||||
conv, err := s.convs.Get(r.Context(), *req.PreviousResponseID)
|
||||
if err != nil {
|
||||
s.logger.ErrorContext(r.Context(), "failed to retrieve conversation",
|
||||
logger.LogAttrsWithTrace(r.Context(),
|
||||
@@ -186,7 +186,7 @@ func (s *GatewayServer) handleSyncResponse(w http.ResponseWriter, r *http.Reques
|
||||
ToolCalls: result.ToolCalls,
|
||||
}
|
||||
allMsgs := append(storeMsgs, assistantMsg)
|
||||
if _, err := s.convs.Create(responseID, result.Model, allMsgs); err != nil {
|
||||
if _, err := s.convs.Create(r.Context(), responseID, result.Model, allMsgs); err != nil {
|
||||
s.logger.ErrorContext(r.Context(), "failed to store conversation",
|
||||
logger.LogAttrsWithTrace(r.Context(),
|
||||
slog.String("request_id", logger.FromContext(r.Context())),
|
||||
@@ -543,7 +543,7 @@ loop:
|
||||
ToolCalls: toolCalls,
|
||||
}
|
||||
allMsgs := append(storeMsgs, assistantMsg)
|
||||
if _, err := s.convs.Create(responseID, model, allMsgs); err != nil {
|
||||
if _, err := s.convs.Create(r.Context(), responseID, model, allMsgs); err != nil {
|
||||
s.logger.ErrorContext(r.Context(), "failed to store conversation",
|
||||
slog.String("request_id", logger.FromContext(r.Context())),
|
||||
slog.String("response_id", responseID),
|
||||
|
||||
Reference in New Issue
Block a user