GoogleCloudPlatform/microservices-demo · error

failed to send request

Error message

failed to send request

What it means

http.DefaultClient.Do failed at transport level when POSTing to the shopping assistant: connection refused, DNS failure, or timeout. The request object was built successfully, so this is purely a backend reachability failure.

Source

Thrown at src/frontend/handlers.go:474

	type LLMResponse struct {
		Content string         `json:"content"`
		Details map[string]any `json:"details"`
	}

	var response LLMResponse

	url := "http://" + fe.shoppingAssistantSvcAddr
	req, err := http.NewRequest(http.MethodPost, url, r.Body)
	if err != nil {
		renderHTTPError(log, r, w, errors.Wrap(err, "failed to create request"), http.StatusInternalServerError)
		return
	}
	req.Header.Set("Content-Type", "application/json")
	req.Header.Set("Accept", "application/json")
	res, err := http.DefaultClient.Do(req)
	if err != nil {
		renderHTTPError(log, r, w, errors.Wrap(err, "failed to send request"), http.StatusInternalServerError)
		return
	}

	body, err := io.ReadAll(res.Body)
	if err != nil {
		renderHTTPError(log, r, w, errors.Wrap(err, "failed to read response"), http.StatusInternalServerError)
		return
	}

	fmt.Printf("%+v\n", body)
	fmt.Printf("%+v\n", res)

	err = json.Unmarshal(body, &response)
	if err != nil {
		renderHTTPError(log, r, w, errors.Wrap(err, "failed to unmarshal body"), http.StatusInternalServerError)
		return
	}

View on GitHub (pinned to 72ba613a05)

Solutions

  1. Verify the shopping assistant service is running and its address/port are correct.
  2. Use an http.Client with an explicit Timeout instead of http.DefaultClient.
  3. Retry transient network errors with backoff.
  4. Check network policies and service discovery between frontend and assistant.
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at src/frontend/handlers.go:474 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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