{"record":{"id":"f924ed9e3e6ebb42","repo":"GoogleCloudPlatform/microservices-demo","slug":"could-not-retrieve-product-s","errorCode":null,"errorMessage":"could not retrieve product #%s","messagePattern":"could not retrieve product #(.+?)","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"src/frontend/handlers.go","lineNumber":287,"sourceCode":"\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 {\n\t\t\trenderHTTPError(log, r, w, errors.Wrapf(err, \"could not convert currency for product #%s\", item.GetProductId()), http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\n\t\tmultPrice := money.MultiplySlow(*price, uint32(item.GetQuantity()))\n\t\titems[i] = cartItemView{\n\t\t\tItem:     p,\n\t\t\tQuantity: item.GetQuantity(),\n\t\t\tPrice:    &multPrice}\n\t\ttotalPrice = money.Must(money.Sum(totalPrice, multPrice))\n\t}\n\ttotalPrice = money.Must(money.Sum(totalPrice, *shippingCost))\n\tyear := time.Now().Year()\n","sourceCodeStart":269,"sourceCodeEnd":305,"githubUrl":"https://github.com/GoogleCloudPlatform/microservices-demo/blob/72ba613a05f7fcee51cf1d0badff401b6ae7074d/src/frontend/handlers.go#L269-L305","documentation":"While building the cart item views, viewCartHandler failed to fetch one of the products in the cart from productcatalogservice (fe.getProduct). The error uses errors.Wrapf with the product ID and is rendered as HTTP 500, aborting the whole cart page.","triggerScenarios":"GET /cart when any product_id stored in the cart no longer resolves via productcatalogservice (item removed from catalog) or the catalog RPC fails.","commonSituations":"cart contains a stale product ID after a catalog update/redeploy of productcatalogservice data, catalog service outage, PRODUCT_CATALOG_SERVICE_ADDR misconfigured.","solutions":["Remove the offending product ID from the user's cart or purge stale cart entries.","Check productcatalogservice availability and its data file.","Verify PRODUCT_CATALOG_SERVICE_ADDR configuration.","Skip missing products gracefully (warn + exclude item) instead of failing the entire cart page."],"exampleFix":"// before\np, err := fe.getProduct(r.Context(), item.GetProductId())\nif err != nil {\n    renderHTTPError(log, r, w, errors.Wrapf(err, \"could not retrieve product #%s\", item.GetProductId()), http.StatusInternalServerError)\n// after\np, err := fe.getProduct(r.Context(), item.GetProductId())\nif err != nil {\n    log.WithField(\"product\", item.GetProductId()).Warn(\"product missing from catalog, skipping cart item\")\n    continue // or remove item from cart via fe.insertCart(..., 0)","handlingStrategy":"fallback","validationCode":"// check cart entries reference live catalog IDs before rendering\nfor _, item := range cart {\n    if item.GetProductId() == \"\" {\n        log.Warn(\"cart item missing product id\")\n    }\n}","typeGuard":null,"tryCatchPattern":"p, err := fe.getProduct(r.Context(), item.GetProductId())\nif err != nil {\n    log.WithField(\"product\", item.GetProductId()).Warn(\"missing product; skipping cart item\")\n    continue\n}","preventionTips":["Purge cart items whose products no longer exist in the catalog.","Skip/omit missing products instead of returning HTTP 500 for the page.","Keep catalog data stable across deploys or version product IDs.","Monitor catalog lookups failing with NotFound from cart views."],"tags":["grpc","http-500","catalog","cart"],"backgroundTag":"stale-cart-item-product-missing","analyzedSha":"72ba613a05f7fcee51cf1d0badff401b6ae7074d","analyzedAt":"2026-09-02T01:15:09.673Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}