Tencent/WeKnora · error

Metaso API returned status %d: %s

Error message

Metaso API returned status %d: %s

What it means

Returned by metasoHTTPError when the Metaso API responds with a non-2xx status and its body parsed as JSON containing a message or error field — the detail is embedded after the status code. Usually an invalid API key (401), quota/credit exhaustion (402/429), or bad request (400).

Source

Thrown at internal/infrastructure/web_search/metaso.go:165

	}
	if len(body) > maxMetasoResponseBytes {
		return nil, fmt.Errorf("Metaso response exceeds %d bytes", maxMetasoResponseBytes)
	}
	return body, nil
}

func metasoHTTPError(statusCode int, body []byte) error {
	var apiError struct {
		Message string `json:"message"`
		Error   string `json:"error"`
	}
	if json.Unmarshal(body, &apiError) == nil {
		detail := strings.TrimSpace(apiError.Message)
		if detail == "" {
			detail = strings.TrimSpace(apiError.Error)
		}
		if detail != "" {
			return fmt.Errorf("Metaso API returned status %d: %s", statusCode, detail)
		}
	}
	detail := strings.TrimSpace(string(body))
	if len(detail) > 4096 {
		detail = detail[:4096]
	}
	if detail == "" {
		return fmt.Errorf("Metaso API returned status %d", statusCode)
	}
	return fmt.Errorf("Metaso API returned status %d: %s", statusCode, detail)
}

func parseMetasoDate(value string) (time.Time, bool) {
	for _, layout := range []string{time.RFC3339Nano, "2006-01-02 15:04:05", "2006-01-02"} {
		if parsed, err := time.Parse(layout, strings.TrimSpace(value)); err == nil {
			return parsed, true
		}
	}

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Use the embedded detail to identify the failure
  2. On 401 verify/rotate the Metaso API key
  3. On 429 back off and reduce request rate
  4. On 5xx retry with backoff
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at internal/infrastructure/web_search/metaso.go:165 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02). Data as JSON: /api/errors/268e11f8499dacb7. Report an issue: GitHub.