Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions go/internal/httpserver/handlers/agents.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,11 @@ func (h *AgentsHandler) HandleListAgents(w ErrorResponseWriter, r *http.Request)

agent, err := h.DatabaseService.GetAgent(teamRef)
if err != nil {
w.RespondWithError(errors.NewNotFoundError("Agent not found", err))
return
// TODO: Rather than excluding the agent completely we should
// probably return it but mark it as "unhealthy" in some way so this
// is visible to callers (e.g. in the UI)
log.Error(err, "failed to load agent from database", "agent", teamRef)
Copy link

Copilot AI Jul 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error logging should include more context about the specific error type to help with debugging. Consider logging the error type or checking if it's a specific type of error (e.g., not found vs connection error) before deciding to continue.

Suggested change
log.Error(err, "failed to load agent from database", "agent", teamRef)
if k8serrors.IsNotFound(err) {
log.Error(err, "agent not found in database", "agent", teamRef)
} else if strings.Contains(err.Error(), "connection") {
log.Error(err, "database connection error while loading agent", "agent", teamRef)
} else {
log.Error(err, "unexpected error while loading agent from database", "agent", teamRef)
}

Copilot uses AI. Check for mistakes.
continue
}

agentResponse, err := h.getAgentResponse(r.Context(), log, &team, agent)
Expand Down