chenhg5/cc-connect · error

minimax tts: request: %w

Error message

minimax tts: request: %w

What it means

This error wraps a failure of m.Client.Do(req) — the actual HTTP round-trip to MiniMax's /v1/t2a_v2 endpoint. It covers connection failures, DNS errors, TLS problems, and context cancellation/deadline exceeded during the request. No HTTP response was received, so the failure is at the network/transport layer.

Source

Thrown at core/tts.go:343

			"sample_rate": 32000,
		},
	}
	jsonData, err := json.Marshal(reqBody)
	if err != nil {
		return nil, "", fmt.Errorf("minimax tts: marshal request: %w", err)
	}

	url := strings.TrimRight(m.BaseURL, "/") + "/v1/t2a_v2"
	req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, bytes.NewReader(jsonData))
	if err != nil {
		return nil, "", fmt.Errorf("minimax tts: create request: %w", err)
	}
	req.Header.Set("Authorization", "Bearer "+m.APIKey)
	req.Header.Set("Content-Type", "application/json")

	resp, err := m.Client.Do(req)
	if err != nil {
		return nil, "", fmt.Errorf("minimax tts: request: %w", err)
	}
	defer resp.Body.Close()

	if resp.StatusCode != http.StatusOK {
		body, _ := io.ReadAll(resp.Body)
		return nil, "", fmt.Errorf("minimax tts API %d: %s", resp.StatusCode, body)
	}

	// Parse SSE stream: each line is "data: {...}" with hex-encoded audio chunks.
	var audioBuf bytes.Buffer
	scanner := bufio.NewScanner(resp.Body)
	scanner.Buffer(make([]byte, 0, 1024*1024), 10*1024*1024)
	for scanner.Scan() {
		select {
		case <-ctx.Done():
			return nil, "", ctx.Err()
		default:
		}

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Verify outbound connectivity to the MiniMax host: curl -v <base_url>/v1/t2a_v2 from the same machine.
  2. Unwrap the error and check for context.DeadlineExceeded / context.Canceled; if deadline, raise the client timeout.
  3. Check proxy environment variables (HTTPS_PROXY/HTTP_PROXY) and TLS setup if behind a corporate proxy.
  4. Fix the base_url in config.toml if it points at an unreachable or misspelled host.
  5. For transient network errors, retry Synthesize with backoff.
Defensive patterns

Strategy: retry

Validate before calling

if u, err := url.Parse(cfg.BaseURL); err != nil || u.Host == "" { return fmt.Errorf("invalid base_url") }
// smoke-test reachability at startup
resp, err := http.DefaultClient.Get(cfg.BaseURL)

Try / catch

audio, format, err := tts.Synthesize(ctx, text, voice)
if err != nil && strings.Contains(err.Error(), "minimax tts: request:") {
    if ne, ok := err.(*net.OpError); ok || errors.Is(err, context.DeadlineExceeded) {
        // transient network: retry with backoff
    }
}

Prevention

When it happens

Trigger: MiniMax API host unreachable or DNS resolution fails; TLS handshake error (bad proxy, clock skew, blocked egress); ctx deadline exceeded while the request was in flight; network drop mid-request.

Common situations: Running in a container or CI without outbound internet access; corporate proxy not configured (HTTPS_PROXY unset); base_url pointing at a wrong/unreachable host; too-short HTTP client timeout for TTS generation.

Related errors


AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06). Data as JSON: /api/errors/e4c7cb447e6dbafa. Report an issue: GitHub.