Skip to content

Make proxy/API error messages locale-aware or configurable #1321

Description

@etwk

Summary

API/proxy-facing error responses can currently return Chinese text to non-Chinese API clients. This is useful for Chinese users, but it creates an i18n mismatch for deployments serving English or other-language clients through OpenAI/Claude/Gemini-compatible APIs.

This is not asking to remove the Chinese messages. The request is to make the API-facing error language locale-aware or operator-configurable.

Current behavior

Some client-visible proxy errors are concrete Chinese strings in code/default data, for example:

  • src/app/v1/_lib/proxy/errors.ts defines the all-providers-unavailable fallback message as Chinese.
  • src/repository/error-rules.ts seeds DEFAULT_ERROR_RULES with overrideResponse.error.message values in Chinese.
  • src/i18n/config.ts sets the app default locale to zh-CN, but API/proxy error responses do not appear to negotiate or select language separately.

Related context: #349 intentionally added preset Chinese return prompts for default client error rules. This issue is about making that behavior configurable or localized for API consumers.

Why this matters

For machine-facing compatible APIs, the caller may not be using the Web UI locale at all. A non-Chinese client can receive an OpenAI/Claude-compatible error body whose error.message is Chinese, even if the request has Accept-Language: en or the deployment operator wants English API errors.

This makes downstream logs, user-facing client errors, and automated integrations harder to understand in non-Chinese environments.

Expected behavior

There should be a supported way to choose the language for API/proxy error messages, while preserving the existing Chinese defaults for zh-CN users.

Possible approaches:

  • Respect Accept-Language for API/proxy error responses when available.
  • Add an operator setting/env var such as a default API error locale.
  • Store default error-rule override messages as message keys or per-locale response templates instead of a single hard-coded language.
  • Keep the response shape stable for OpenAI/Claude/Gemini-compatible clients.
  • Preserve custom database error-rule overrides during default rule sync.

Example reproduction

  1. Deploy a fresh instance.
  2. Trigger a default proxy error or a default error-rule override, such as an all-providers-unavailable case or a prompt/model validation rule.
  3. Send the request from a non-Chinese API client, optionally with Accept-Language: en.
  4. Observe that the returned compatible API error body can contain a Chinese error.message.

Acceptance criteria

  • Existing Chinese messages still work for Chinese locale/users.
  • Non-Chinese API clients can receive English or configured-locale error messages without editing source code.
  • Default error-rule sync does not overwrite operator/custom localized overrides unexpectedly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status
    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions