{"record":{"id":"7c512f394177c214","repo":"GoogleCloudPlatform/microservices-demo","slug":"failed-to-get-shipping-quote","errorCode":null,"errorMessage":"failed to get shipping quote","messagePattern":"failed to get shipping quote","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"src/frontend/handlers.go","lineNumber":273,"sourceCode":"\tif err != nil {\n\t\trenderHTTPError(log, r, w, errors.Wrap(err, \"could not retrieve currencies\"), http.StatusInternalServerError)\n\t\treturn\n\t}\n\tcart, err := fe.getCart(r.Context(), sessionID(r))\n\tif err != nil {\n\t\trenderHTTPError(log, r, w, errors.Wrap(err, \"could not retrieve cart\"), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\t// ignores the error retrieving recommendations since it is not critical\n\trecommendations, err := fe.getRecommendations(r.Context(), sessionID(r), cartIDs(cart))\n\tif err != nil {\n\t\tlog.WithField(\"error\", err).Warn(\"failed to get product recommendations\")\n\t}\n\n\tshippingCost, err := fe.getShippingQuote(r.Context(), cart, currentCurrency(r))\n\tif err != nil {\n\t\trenderHTTPError(log, r, w, errors.Wrap(err, \"failed to get shipping quote\"), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\ttype cartItemView struct {\n\t\tItem     *pb.Product\n\t\tQuantity int32\n\t\tPrice    *pb.Money\n\t}\n\titems := make([]cartItemView, len(cart))\n\ttotalPrice := pb.Money{CurrencyCode: currentCurrency(r)}\n\tfor i, item := range cart {\n\t\tp, err := fe.getProduct(r.Context(), item.GetProductId())\n\t\tif err != nil {\n\t\t\trenderHTTPError(log, r, w, errors.Wrapf(err, \"could not retrieve product #%s\", item.GetProductId()), http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\t\tprice, err := fe.convertCurrency(r.Context(), p.GetPriceUsd(), currentCurrency(r))\n\t\tif err != nil {","sourceCodeStart":255,"sourceCodeEnd":291,"githubUrl":"https://github.com/GoogleCloudPlatform/microservices-demo/blob/72ba613a05f7fcee51cf1d0badff401b6ae7074d/src/frontend/handlers.go#L255-L291","documentation":"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.","triggerScenarios":"GET /cart when shippingservice GetQuote errors: service down, invalid Money (empty currency code or zero units) in the request, or timeout.","commonSituations":"shippingservice pod unavailable, SHIPPING_SERVICE_ADDR misconfigured, cart items with malformed prices (e.g. currency conversion produced a zero-value Money), request deadline exceeded.","solutions":["Check shippingservice health and logs.","Verify SHIPPING_SERVICE_ADDR in frontend env.","Validate cart items and currency code before calling GetQuote.","Consider rendering the cart without shipping cost with a warning instead of 500."],"exampleFix":"// before\nshippingCost, err := fe.getShippingQuote(r.Context(), cart, currentCurrency(r))\nif err != nil {\n    renderHTTPError(log, r, w, errors.Wrap(err, \"failed to get shipping quote\"), http.StatusInternalServerError)\n// after\nshippingCost, err := fe.getShippingQuote(r.Context(), cart, currentCurrency(r))\nif err != nil {\n    log.WithField(\"error\", err).Warn(\"shipping quote unavailable\")\n    shippingCost = nil // render cart without shipping cost","handlingStrategy":"fallback","validationCode":"for _, it := range cart {\n    if it.GetQuantity() <= 0 {\n        log.Warn(\"cart contains invalid quantity; quote may fail\")\n    }\n}","typeGuard":null,"tryCatchPattern":"shippingCost, err := fe.getShippingQuote(r.Context(), cart, currentCurrency(r))\nif err != nil {\n    log.WithField(\"error\", err).Warn(\"shipping quote unavailable\")\n    shippingCost = nil\n}","preventionTips":["Ensure cart items carry valid Money values before GetQuote.","Validate the currency code against Supported first.","Keep shippingservice address config verified at startup.","Render the cart without shipping instead of failing the whole page."],"tags":["grpc","http-500","shipping","microservices"],"backgroundTag":"rpc-service-unavailable","analyzedSha":"72ba613a05f7fcee51cf1d0badff401b6ae7074d","analyzedAt":"2026-09-02T01:15:09.673Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}