diff --git a/utils/utils.go b/utils/utils.go
index 6e4d65d..c95e198 100644
--- a/utils/utils.go
+++ b/utils/utils.go
@@ -77,30 +77,57 @@
 }
 
 func buildLineItem(availability *fpb.Availability, tickets []*fpb.TicketType) *mpb.LineItem {
+	// If no ticket types return nil as there is nothing to build.
+	if len(tickets) == 0 {
+		return nil
+	}
+
+	// Treated as a set.
+	ticketMap := make(map[string]*fpb.TicketType)
+	for _, ticketType := range tickets {
+		if _, ok := ticketMap[ticketType.GetTicketTypeId()]; !ok {
+			// Ticket type ids should be unique to a merchant service pair.
+			// If they're not unique they will get dropped silently here.
+			// We enforce minimal feed validation in the test client so it's
+			// up to you to ensure UIDs.
+			ticketMap[ticketType.GetTicketTypeId()] = ticketType
+		}
+	}
+
+	filteredTickets := tickets
+	if len(availability.GetTicketTypeId()) != 0 {
+		// Clear slice but preserve allocated memory.
+		filteredTickets = filteredTickets[:0]
+		for _, ticketTypeID := range availability.GetTicketTypeId() {
+			if ticketType, ok := ticketMap[ticketTypeID]; ok {
+				filteredTickets = append(filteredTickets, ticketType)
+			}
+		}
+	}
+
+	// If no ticket types return nil as there is nothing to build.
+	if len(filteredTickets) == 0 {
+		return nil
+	}
+
 	lineItem := &mpb.LineItem{
 		ServiceId:   availability.GetServiceId(),
 		StartSec:    availability.GetStartSec(),
 		DurationSec: availability.GetDurationSec(),
 		Price:       &mpb.Price{},
 	}
-
-	// If not ticket types return nil as there is nothing to build.
-	if len(tickets) == 0 {
-		return nil
-	}
-
 	for i := 0; i < int(availability.GetSpotsOpen()); i++ {
 		// This is deterministic which is fine given that we just want to get a mix of ticket types.
-		ticketTypeIndex := rand.Intn(len(tickets))
+		ticketTypeIndex := rand.Intn(len(filteredTickets))
 		// Calculate price of line item.
-		if lineItem.GetPrice().GetCurrencyCode() == "" && tickets[ticketTypeIndex].GetPrice().GetCurrencyCode() != "" {
-			lineItem.Price.CurrencyCode = tickets[ticketTypeIndex].GetPrice().GetCurrencyCode()
+		if lineItem.GetPrice().GetCurrencyCode() == "" && filteredTickets[ticketTypeIndex].GetPrice().GetCurrencyCode() != "" {
+			lineItem.Price.CurrencyCode = filteredTickets[ticketTypeIndex].GetPrice().GetCurrencyCode()
 		}
-		lineItem.Price.PriceMicros += tickets[ticketTypeIndex].GetPrice().GetPriceMicros()
+		lineItem.Price.PriceMicros += filteredTickets[ticketTypeIndex].GetPrice().GetPriceMicros()
 
 		// Add ticket to line item.
 		lineItem.Tickets = append(lineItem.Tickets, &mpb.LineItem_OrderedTickets{
-			TicketId: tickets[ticketTypeIndex].GetTicketTypeId(),
+			TicketId: filteredTickets[ticketTypeIndex].GetTicketTypeId(),
 			Count:    1,
 		})
 	}
