diff --git a/pkg/grpc/actions/agents/common.go b/pkg/grpc/actions/agents/common.go index 10515d7a10..2347354b90 100644 --- a/pkg/grpc/actions/agents/common.go +++ b/pkg/grpc/actions/agents/common.go @@ -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" @@ -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 @@ -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 diff --git a/pkg/grpc/actions/agents/get_canvas_agent_chat.go b/pkg/grpc/actions/agents/get_canvas_agent_chat.go index 77230c053c..b14cc99ae3 100644 --- a/pkg/grpc/actions/agents/get_canvas_agent_chat.go +++ b/pkg/grpc/actions/agents/get_canvas_agent_chat.go @@ -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