{"record":{"id":"1b0f597811ea2567","repo":"GoogleCloudPlatform/microservices-demo","slug":"could-not-retrieve-currencies","errorCode":null,"errorMessage":"could not retrieve currencies","messagePattern":"could not retrieve currencies","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"src/frontend/handlers.go","lineNumber":64,"sourceCode":"\tfrontendMessage  = strings.TrimSpace(os.Getenv(\"FRONTEND_MESSAGE\"))\n\tisCymbalBrand    = \"true\" == strings.ToLower(os.Getenv(\"CYMBAL_BRANDING\"))\n\tassistantEnabled = \"true\" == strings.ToLower(os.Getenv(\"ENABLE_ASSISTANT\"))\n\ttemplates        = template.Must(template.New(\"\").\n\t\t\t\tFuncs(template.FuncMap{\n\t\t\t\"renderMoney\":        renderMoney,\n\t\t\t\"renderCurrencyLogo\": renderCurrencyLogo,\n\t\t}).ParseGlob(\"templates/*.html\"))\n\tplat platformDetails\n)\n\nvar validEnvs = []string{\"local\", \"gcp\", \"azure\", \"aws\", \"onprem\", \"alibaba\"}\n\nfunc (fe *frontendServer) homeHandler(w http.ResponseWriter, r *http.Request) {\n\tlog := r.Context().Value(ctxKeyLog{}).(logrus.FieldLogger)\n\tlog.WithField(\"currency\", currentCurrency(r)).Info(\"home\")\n\tcurrencies, err := fe.getCurrencies(r.Context())\n\tif err != nil {\n\t\trenderHTTPError(log, r, w, errors.Wrap(err, \"could not retrieve currencies\"), http.StatusInternalServerError)\n\t\treturn\n\t}\n\tproducts, err := fe.getProducts(r.Context())\n\tif err != nil {\n\t\trenderHTTPError(log, r, w, errors.Wrap(err, \"could not retrieve products\"), 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\ttype productView struct {\n\t\tItem  *pb.Product\n\t\tPrice *pb.Money\n\t}\n\tps := make([]productView, len(products))","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/GoogleCloudPlatform/microservices-demo/blob/72ba613a05f7fcee51cf1d0badff401b6ae7074d/src/frontend/handlers.go#L46-L82","documentation":"homeHandler fetches supported currencies via fe.getCurrencies (gRPC to the currency service). On any error it wraps with errors.Wrap(err, \"could not retrieve currencies\") and renders HTTP 500. This indicates the frontend could not obtain the currency list, so the home page cannot render prices.","triggerScenarios":"fe.getCurrencies(r.Context()) returns error: currency service unavailable, RPC deadline exceeded, or empty/error response from CurrencyService.GetSupportedCurrencies.","commonSituations":"Currency service pod down or crash-looping; CURRENCY_SERVICE_ADDR wrong; context deadline exceeded under load; network policy blocking frontend→currency traffic; service not deployed in the cluster.","solutions":["Check currency service health/deployment (kubectl get pods, logs)","Verify CURRENCY_SERVICE_ADDR resolves to the currency service host:port","Inspect the wrapped cause (%+v / errors.Unwrap) for the gRPC status code","Increase context timeout if DeadlineExceeded under load","Add a fallback default currency list so the home page renders when currency service is down"],"exampleFix":"// before\ncurrencies, err := fe.getCurrencies(r.Context())\nif err != nil {\n    renderHTTPError(log, r, w, errors.Wrap(err, \"could not retrieve currencies\"), http.StatusInternalServerError)\n    return\n}\n// after\ncurrencies, err := fe.getCurrencies(r.Context())\nif err != nil {\n    log.WithError(err).Warn(\"could not retrieve currencies, using fallback\")\n    currencies = defaultCurrencies\n}","handlingStrategy":"fallback","validationCode":"if cs.currencySvcConn == nil {\n    return nil, errors.New(\"currency service connection not initialized\")\n}","typeGuard":null,"tryCatchPattern":"currencies, err := fe.getCurrencies(r.Context())\nif err != nil {\n    log.WithError(err).Warn(\"currency list unavailable, using fallback\")\n    currencies = defaultCurrencies\n}","preventionTips":["Deploy readiness/liveness probes for the currency service","Cache the supported-currencies list in the frontend","Verify CURRENCY_SERVICE_ADDR during deploy checks","Set sane RPC timeouts and retry on Unavailable"],"tags":["grpc","http","frontend","microservices","currency"],"backgroundTag":"grpc-rpc-failed","analyzedSha":"72ba613a05f7fcee51cf1d0badff401b6ae7074d","analyzedAt":"2026-09-02T01:15:09.673Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}