Skip to content
Draft
Show file tree
Hide file tree
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
11 changes: 11 additions & 0 deletions pkg/grpc/actions/agents/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"errors"

"github.com/google/uuid"
log "github.com/sirupsen/logrus"
agentservice "github.com/superplanehq/superplane/pkg/agents"
"github.com/superplanehq/superplane/pkg/models"
pb "github.com/superplanehq/superplane/pkg/protos/agents"
Expand Down Expand Up @@ -38,10 +39,16 @@ func agentModeFromProto(mode pb.AgentMode) string {
func parseOrgUser(orgID, userID string) (org, user uuid.UUID, err error) {
org, err = uuid.Parse(orgID)
if err != nil {
log.WithError(err).
WithField("organization_id", orgID).
Error("agent request received an invalid organization id")
return uuid.Nil, uuid.Nil, status.Error(codes.Internal, "invalid organization")
}
user, err = uuid.Parse(userID)
if err != nil {
log.WithError(err).
WithField("user_id", userID).
Error("agent request received an invalid user id")
return uuid.Nil, uuid.Nil, status.Error(codes.Internal, "invalid user")
}
return org, user, nil
Expand All @@ -52,6 +59,10 @@ func ensureCanvas(orgID, canvasID uuid.UUID) error {
if errors.Is(err, gorm.ErrRecordNotFound) {
return status.Error(codes.NotFound, "canvas not found")
}
log.WithError(err).
WithField("organization_id", orgID.String()).
WithField("canvas_id", canvasID.String()).
Error("failed to load canvas for agent request")
return status.Error(codes.Internal, "failed to load canvas")
}
return nil
Expand Down
6 changes: 5 additions & 1 deletion pkg/grpc/actions/agents/get_canvas_agent_chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ func GetCanvasAgentChat(ctx context.Context, svc AgentsService, orgID, userID st
if errors.Is(err, agents.ErrSessionForbidden) {
return nil, status.Error(codes.PermissionDenied, "agent chat is not allowed")
}
log.WithError(err).WithField("canvas_id", canvas).Error("failed to ensure agent chat")
log.WithError(err).
WithField("canvas_id", canvas.String()).
WithField("organization_id", org.String()).
WithField("user_id", user.String()).
Error("failed to ensure agent chat")
return nil, status.Error(codes.Internal, "failed to load agent chat")
}
return &pb.GetCanvasAgentChatResponse{Chat: serializeChat(session)}, nil
Expand Down
Loading