Tongyi LLM plugin incorrectly handles provider error responses #613

Closed
opened 2026-02-16 10:19:55 -05:00 by yindo · 1 comment
Owner

Originally created by @laipz8200 on GitHub (Sep 2, 2025).

Originally assigned to: @laipz8200 on GitHub.

Current Behavior:
The Tongyi LLM plugin currently treats all API error responses as ServiceUnavailableError regardless of the actual HTTP status code returned by the provider.

Expected Behavior:
Different HTTP status codes should be mapped to appropriate error types:

  • 400, 422: BadRequestError
  • 401, 403: AuthorizationError
  • 429: RateLimitError
  • 500+: ServerUnavailableError

Impact:
This affects proper error handling and user experience when using the Tongyi LLM plugin, as users cannot distinguish between different types of errors (authentication issues, rate limits, bad requests, etc.).

Environment:

  • Plugin: Tongyi LLM
  • Current Version: 0.0.43
Originally created by @laipz8200 on GitHub (Sep 2, 2025). Originally assigned to: @laipz8200 on GitHub. **Current Behavior:** The Tongyi LLM plugin currently treats all API error responses as ServiceUnavailableError regardless of the actual HTTP status code returned by the provider. **Expected Behavior:** Different HTTP status codes should be mapped to appropriate error types: - 400, 422: BadRequestError - 401, 403: AuthorizationError - 429: RateLimitError - 500+: ServerUnavailableError **Impact:** This affects proper error handling and user experience when using the Tongyi LLM plugin, as users cannot distinguish between different types of errors (authentication issues, rate limits, bad requests, etc.). **Environment:** - Plugin: Tongyi LLM - Current Version: 0.0.43
yindo added the bug label 2026-02-16 10:19:55 -05:00
yindo closed this issue 2026-02-16 10:19:55 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Sep 2, 2025):

You're correct—the Tongyi LLM plugin currently raises a ServiceUnavailableError for any non-200 response, regardless of the actual HTTP status code. This logic is in the TongyiLLMModel class's _chat method, and there isn't any mapping for specific status codes to error types like BadRequestError, AuthorizationError, or RateLimitError, which leads to ambiguous error reporting for users source.

To improve error handling, you can update the _chat method to check the response status code and raise the appropriate error type. For example: raise BadRequestError for 400/422, AuthorizationError for 401/403, RateLimitError for 429, and ServerUnavailableError for 500+. No recent pull requests address this, so a code change is needed in models/tongyi/models/llm/tongyi.py.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Join Discord Share on X

@dosubot[bot] commented on GitHub (Sep 2, 2025): <!-- Answer --> You're correct—the Tongyi LLM plugin currently raises a ServiceUnavailableError for any non-200 response, regardless of the actual HTTP status code. This logic is in the TongyiLLMModel class's _chat method, and there isn't any mapping for specific status codes to error types like BadRequestError, AuthorizationError, or RateLimitError, which leads to ambiguous error reporting for users [source](https://github.com/langgenius/dify/issues/23887). To improve error handling, you can update the _chat method to check the response status code and raise the appropriate error type. For example: raise BadRequestError for 400/422, AuthorizationError for 401/403, RateLimitError for 429, and ServerUnavailableError for 500+. No recent pull requests address this, so a code change is needed in models/tongyi/models/llm/tongyi.py. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/9b236faf-e561-483d-b1ca-5efd854ed67a?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/9b236faf-e561-483d-b1ca-5efd854ed67a?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/9b236faf-e561-483d-b1ca-5efd854ed67a?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/9b236faf-e561-483d-b1ca-5efd854ed67a?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/9b236faf-e561-483d-b1ca-5efd854ed67a?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/9b236faf-e561-483d-b1ca-5efd854ed67a?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/9b236faf-e561-483d-b1ca-5efd854ed67a?feedback_type=other)</sup>&nbsp;&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify-official-plugins/issues/1635)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-official-plugins#613