GoogleCloudPlatform/microservices-demo · warning
product id not specified
Error message
product id not specified
What it means
The frontend productHandler requires a product id from the URL route variable. If the id captured by the mux route is empty, it renders a 400 Bad Request page with 'product id not specified' instead of trying to fetch the product.
Source
Thrown at src/frontend/handlers.go:148
plat.provider = "Azure"
plat.css = "azure-platform"
} else if env == "gcp" {
plat.provider = "Google Cloud"
plat.css = "gcp-platform"
} else if env == "alibaba" {
plat.provider = "Alibaba Cloud"
plat.css = "alibaba-platform"
} else {
plat.provider = "local"
plat.css = "local"
}
}
func (fe *frontendServer) productHandler(w http.ResponseWriter, r *http.Request) {
log := r.Context().Value(ctxKeyLog{}).(logrus.FieldLogger)
id := mux.Vars(r)["id"]
if id == "" {
renderHTTPError(log, r, w, errors.New("product id not specified"), http.StatusBadRequest)
return
}
log.WithField("id", id).WithField("currency", currentCurrency(r)).
Debug("serving product page")
p, err := fe.getProduct(r.Context(), id)
if err != nil {
renderHTTPError(log, r, w, errors.Wrap(err, "could not retrieve product"), http.StatusInternalServerError)
return
}
currencies, err := fe.getCurrencies(r.Context())
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 {View on GitHub (pinned to 72ba613a05)
Solutions
- Fix the source of the request: ensure the URL is /product/<valid-id>
- Check reverse proxy/rewrite rules preserve the id path segment
- Validate/guard links in templates that render product hrefs
- Return a friendlier 404/redirect from productHandler for empty ids
Example fix
<!-- before -->
<a href="/product/">View</a>
<!-- after -->
<a href="/product/{{.Item.Id}}">View</a> Defensive patterns
Strategy: validation
Validate before calling
// client-side link check before navigating
const id = new URL(url).pathname.split('/').pop();
if (!id) { console.warn('product link missing id:', url); return; } Prevention
- Validate product hrefs in templates render a non-empty id
- Test routes /product/{id} end-to-end including behind reverse proxies
- Return a friendly 404 page for missing ids instead of a bare 400
- Monitor logs for repeated 'product id not specified' to find broken link sources
When it happens
Trigger: An HTTP GET to /product/ with an empty id segment, a rewritten/proxied URL that drops the {id} path variable, or a stale link pointing at /product without an id.
Common situations: Broken or hand-edited product links in emails/marketing; reverse-proxy rewrite rules mangling the path; users bookmarking a truncated URL; templates generating hrefs with an empty id.
Related errors
- Unexpected status code: %d
- could not retrieve currencies
- could not retrieve products
- could not retrieve cart
- one of the specified money values is invalid
AI-assisted analysis of GoogleCloudPlatform/microservices-demo@72ba613a05 (2026-09-02).
Data as JSON: /api/errors/5c127529c40e0a0b.
Report an issue: GitHub.