Skip to content

fix(model): map upstream provider errors - #1732

Merged
zhoujh01 merged 1 commit into
mainfrom
fix/upstream-model-error-mapping
Apr 27, 2026
Merged

zhoujh01 merged 1 commit into
mainfrom
fix/upstream-model-error-mapping

Conversation

@qin-ctx

@qin-ctx qin-ctx commented Apr 27, 2026

Copy link
Copy Markdown
Collaborator

Description

Map upstream model provider failures to structured OpenViking API errors instead of falling through to generic 500 responses. This also cleans up provider error messages so duplicated nested exception text is not shown to CLI users.

Related Issue

N/A

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement
  • Test update

Changes Made

  • Added centralized upstream model error mapping for provider HTTP status codes such as 401, 403, 429, 502, and missing API key configuration.
  • Added SDK exception support for standard server error codes including RESOURCE_EXHAUSTED, ABORTED, and UNIMPLEMENTED, while preserving unknown future error codes.
  • Added focused server and client tests covering upstream provider mapping, API key failures, message de-duplication, and client-side error-code passthrough.

Testing

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have tested this on the following platforms:
    • Linux
    • macOS
    • Windows

Checklist

  • My code follows the project's coding style
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

Screenshots (if applicable)

N/A

Additional Notes

Validated with:

  • .venv/bin/ruff check openviking/server/error_mapping.py openviking_cli/client/http.py openviking_cli/exceptions.py tests/server/test_error_mapping.py tests/client/test_http_error_mapping.py
  • .venv/bin/ruff format --check openviking/server/error_mapping.py openviking_cli/client/http.py openviking_cli/exceptions.py tests/server/test_error_mapping.py tests/client/test_http_error_mapping.py
  • .venv/bin/python -m pytest tests/server/test_error_mapping.py tests/client/test_http_error_mapping.py

The pytest run still emits existing dependency/Pydantic deprecation warnings unrelated to this change.

Return structured errors for model provider failures so auth, quota, and service errors are not collapsed into generic 500 responses.
@github-actions

Copy link
Copy Markdown
Contributor

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🏅 Score: 92
🧪 PR contains tests
🔒 No security concerns identified
✅ No TODO sections
🔀 No multiple PR themes
⚡ Recommended focus areas for review

Redundant Check

Duplicate check for model API key configuration error: line 408-412 checks _is_model_api_key_configuration_error before calling _map_upstream_api_error, which already performs the same check. This is redundant but does not affect functionality.

if _is_model_api_key_configuration_error(exc):
    return FailedPreconditionError(
        "Model provider API key is not configured",
        details={"reason": _trim_message(_exception_chain_text(exc))},
    )

@github-actions

Copy link
Copy Markdown
Contributor

PR Code Suggestions ✨

No code suggestions found for the PR.

@zhoujh01
zhoujh01 merged commit 14b8373 into main Apr 27, 2026
6 checks passed
@zhoujh01
zhoujh01 deleted the fix/upstream-model-error-mapping branch April 27, 2026 04:05
@github-project-automation github-project-automation Bot moved this from Backlog to Done in OpenViking project Apr 27, 2026
A0nameless0man pushed a commit to A0nameless0man/OpenViking that referenced this pull request Apr 30, 2026
Return structured errors for model provider failures so auth, quota, and service errors are not collapsed into generic 500 responses.
frankyang2008-eng pushed a commit to frankyang2008-eng/OpenViking that referenced this pull request Oct 9, 2026
Return structured errors for model provider failures so auth, quota, and service errors are not collapsed into generic 500 responses.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants