GoogleCloudPlatform/microservices-demo · error

failed to get shipping quote

Error message

failed to get shipping quote

What it means

viewCartHandler failed to obtain a shipping quote via fe.getShippingQuote (shippingservice GetQuote RPC) for the cart contents in the selected currency. The error is wrapped as "failed to get shipping quote" and rendered as HTTP 500.

Source

Thrown at src/frontend/handlers.go:273

	if err != nil {
		renderHTTPError(log, r, w, errors.Wrap(err, "could not retrieve currencies"), http.StatusInternalServerError)
		return
	}
	cart, err := fe.getCart(r.Context(), sessionID(r))
	if err != nil {
		renderHTTPError(log, r, w, errors.Wrap(err, "could not retrieve cart"), http.StatusInternalServerError)
		return
	}

	// ignores the error retrieving recommendations since it is not critical
	recommendations, err := fe.getRecommendations(r.Context(), sessionID(r), cartIDs(cart))
	if err != nil {
		log.WithField("error", err).Warn("failed to get product recommendations")
	}

	shippingCost, err := fe.getShippingQuote(r.Context(), cart, currentCurrency(r))
	if err != nil {
		renderHTTPError(log, r, w, errors.Wrap(err, "failed to get shipping quote"), http.StatusInternalServerError)
		return
	}

	type cartItemView struct {
		Item     *pb.Product
		Quantity int32
		Price    *pb.Money
	}
	items := make([]cartItemView, len(cart))
	totalPrice := pb.Money{CurrencyCode: currentCurrency(r)}
	for i, item := range cart {
		p, err := fe.getProduct(r.Context(), item.GetProductId())
		if err != nil {
			renderHTTPError(log, r, w, errors.Wrapf(err, "could not retrieve product #%s", item.GetProductId()), http.StatusInternalServerError)
			return
		}
		price, err := fe.convertCurrency(r.Context(), p.GetPriceUsd(), currentCurrency(r))
		if err != nil {

View on GitHub (pinned to 72ba613a05)

Solutions

  1. Check shippingservice health and logs.
  2. Verify SHIPPING_SERVICE_ADDR in frontend env.
  3. Validate cart items and currency code before calling GetQuote.
  4. Consider rendering the cart without shipping cost with a warning instead of 500.

Example fix

// before
shippingCost, err := fe.getShippingQuote(r.Context(), cart, currentCurrency(r))
if err != nil {
    renderHTTPError(log, r, w, errors.Wrap(err, "failed to get shipping quote"), http.StatusInternalServerError)
// after
shippingCost, err := fe.getShippingQuote(r.Context(), cart, currentCurrency(r))
if err != nil {
    log.WithField("error", err).Warn("shipping quote unavailable")
    shippingCost = nil // render cart without shipping cost
Defensive patterns

Strategy: fallback

Validate before calling

for _, it := range cart {
    if it.GetQuantity() <= 0 {
        log.Warn("cart contains invalid quantity; quote may fail")
    }
}

Try / catch

shippingCost, err := fe.getShippingQuote(r.Context(), cart, currentCurrency(r))
if err != nil {
    log.WithField("error", err).Warn("shipping quote unavailable")
    shippingCost = nil
}

Prevention

When it happens

Trigger: GET /cart when shippingservice GetQuote errors: service down, invalid Money (empty currency code or zero units) in the request, or timeout.

Common situations: shippingservice pod unavailable, SHIPPING_SERVICE_ADDR misconfigured, cart items with malformed prices (e.g. currency conversion produced a zero-value Money), request deadline exceeded.

Related errors


AI-assisted analysis of GoogleCloudPlatform/microservices-demo@72ba613a05 (2026-09-02). Data as JSON: /api/errors/7c512f394177c214. Report an issue: GitHub.