Class MiniMaxProviderErrorMapper

java.lang.Object
com.tnsai.llm.errors.MiniMaxProviderErrorMapper
All Implemented Interfaces:
ProviderErrorMapper

public class MiniMaxProviderErrorMapper extends Object implements ProviderErrorMapper
ProviderErrorMapper for MiniMax — twelfth pilot mapper.

MiniMax exposes two error envelopes depending on which endpoint failed; this mapper accepts both because the client (and partner-routed proxies in front of it) can hit either one:

  1. OpenAI-compatible at /chat/completions — what MiniMaxClient actually uses today:
    { "error": { "message": "...", "type": "...", "code": "..." } } 
  2. Native at /text/chatcompletion_v2 — uses a numeric base_resp.status_code channel:
    { "base_resp": { "status_code": 1004, "status_msg": "..." } } 

The native channel is non-trivial — MiniMax routes everything through HTTP 200 even on failure, so the only signal is the JSON status code. Mapper picks base_resp.status_code as the canonical providerCode when present (stringified), else falls back to the OpenAI code field.

Status mappings — native MiniMax codes (numeric):

  • 1002 (rate limit) / 1039 (TPM exceeded) → MODEL_OVERLOADED
  • 1004 (auth failure) → AUTHENTICATION_FAILED
  • 1008 (insufficient balance) → AUTHENTICATION_FAILED (same triage path — provisioning issue, not transient)
  • 1013 (internal service) → SERVER_ERROR
  • 1027 (output filter) / 1042 (prompt filter) → CONTENT_FILTERED
  • 1043 / 2013 (invalid input/params) → INVALID_REQUEST
  • 1001 (timeout) → SERVER_ERROR (transient)

OpenAI-compatible string codes are routed through the same vocabulary the OpenAI mapper uses (rate_limit_exceeded, invalid_api_key, context_length_exceeded, …).

Captured headers: retry-after, x-ratelimit-*, x-request-id, x-trace-id (MiniMax surfaces a trace id on most responses — useful for support tickets).

Since:
0.5.3 (issue #87 follow-up — twelfth pilot mapper)
  • Constructor Details

    • MiniMaxProviderErrorMapper

      public MiniMaxProviderErrorMapper()
  • Method Details

    • providerId

      public String providerId()
      Specified by:
      providerId in interface ProviderErrorMapper
      Returns:
      short, lowercase provider id (e.g. "openai", "anthropic"). Used to route a raw response to the right mapper.
    • map

      public com.tnsai.exceptions.LLMException map(int httpStatus, Map<String,String> responseHeaders, String responseBody, String model, Throwable cause)
      Description copied from interface: ProviderErrorMapper
      Translate a raw HTTP error response into a typed LLMException.
      Specified by:
      map in interface ProviderErrorMapper
      Parameters:
      httpStatus - HTTP status code from the response
      responseHeaders - selected response headers (lower-cased keys); empty map if none captured
      responseBody - raw response body; mapper parses provider-specific envelope (e.g. JSON error.code)
      model - model identifier from the request, for the resulting LLMException.getModel()
      cause - underlying transport throwable, may be null when the failure is purely a non-2xx response
      Returns:
      typed LLMException with ProviderDetails attached
    • mapErrorType

      public Optional<com.tnsai.exceptions.LLMException.ErrorType> mapErrorType(String providerCode)
      Description copied from interface: ProviderErrorMapper
      Map a provider-native error code to a framework LLMException.ErrorType. Implementations should err on the side of LLMException.ErrorType.UNKNOWN for codes they don't recognize so that a new provider error doesn't fail the whole mapping path.
      Specified by:
      mapErrorType in interface ProviderErrorMapper
      Parameters:
      providerCode - native code (e.g. "context_length_exceeded")
      Returns:
      matching LLMException.ErrorType, or Optional.empty() if the mapper has no opinion