Files
wehub-resource-sync 4b6817381b
Benchmark image — build + push to ECR (any adapter) / build + push (push) Waiting to run
CI / quality (ubuntu-latest) (push) Waiting to run
CI / test (tools-runtime) (push) Waiting to run
CI / test (e2e-general) (push) Waiting to run
CI / test (cli-runtime) (push) Waiting to run
CI / test (e2e-provider-and-openclaw) (push) Waiting to run
CI / test (integrations-and-misc) (push) Waiting to run
CI / coverage-report (push) Blocked by required conditions
CI / test-kubernetes (push) Waiting to run
CI / should-run-thorough (push) Waiting to run
CI / test-thorough (cloudwatch-demo) (push) Blocked by required conditions
CI / test-thorough (flink-ecs) (push) Blocked by required conditions
CI / test-thorough (upstream-lambda) (push) Blocked by required conditions
CI / test-thorough (prefect-ecs-fargate) (push) Blocked by required conditions
CodeQL / Analyze (python) (push) Waiting to run
Release / build-binaries (zip, opensre.exe, onefile, windows-latest, windows-x64) (push) Blocked by required conditions
Release / publish-release (push) Blocked by required conditions
Release / publish-main-release (push) Blocked by required conditions
Release / prepare (push) Waiting to run
Release / verify (push) Blocked by required conditions
Release / build-python-dist (push) Blocked by required conditions
Release / build-binaries (tar.gz, opensre, onedir, macos-15-intel, darwin-x64) (push) Blocked by required conditions
Release / build-binaries (tar.gz, opensre, onedir, macos-latest, darwin-arm64) (push) Blocked by required conditions
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04, linux-x64) (push) Blocked by required conditions
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04-arm, linux-arm64) (push) Blocked by required conditions
Synthetic Deterministic Tests / Synthetic offline (deterministic) (push) Waiting to run
Interactive Shell Live (PR + post-merge) / turn-checks (no-LLM) (push) Waiting to run
Interactive Shell Live (PR + post-merge) / turn-live shard ${{ matrix.shard_index }} (push) Waiting to run
CI (OpenClaw E2E) / openclaw test (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:10:45 +08:00

118 lines
4.7 KiB
Python

from __future__ import annotations
import pytest
from core.llm.shared.llm_retry import LLMCreditExhaustedError
from integrations.llm_cli.errors import CLITimeoutError
from surfaces.cli.error_mapping import reraise_cli_runtime_error
from surfaces.interactive_shell.utils.error_handling.errors import OpenSREError
def test_credit_exhausted_error_maps_to_opensre_error_with_auth_hint() -> None:
"""LLMCreditExhaustedError must produce a structured CLI error with an auth login hint."""
exc = LLMCreditExhaustedError(
"Anthropic credit exhausted (provider billing/quota). Original error: 400"
)
with pytest.raises(OpenSREError) as exc_info:
reraise_cli_runtime_error(exc)
err = exc_info.value
assert "credit exhausted" in str(err).lower()
assert err.suggestion is not None
assert "opensre auth login" in err.suggestion
def test_anthropic_model_not_found_raises_opensre_error() -> None:
"""RuntimeError from an invalid Anthropic model name maps to a user-friendly OpenSREError."""
exc = RuntimeError(
"Anthropic model 'not-a-real-model-xyz' was not found. "
"Check your configured model name and try again."
)
with pytest.raises(OpenSREError) as exc_info:
reraise_cli_runtime_error(exc)
err = exc_info.value
assert "not-a-real-model-xyz" in str(err)
assert err.suggestion is not None
assert "ANTHROPIC_REASONING_MODEL" in err.suggestion
assert "ANTHROPIC_TOOLCALL_MODEL" in err.suggestion
def test_anthropic_model_not_found_suggestion_guides_env_vars() -> None:
"""The suggestion must point at the two env vars users are most likely to misconfigure."""
exc = RuntimeError(
"Anthropic model 'bad-model' was not found. Check your configured model name and try again."
)
with pytest.raises(OpenSREError) as exc_info:
reraise_cli_runtime_error(exc)
assert exc_info.value.suggestion is not None
assert "ANTHROPIC_REASONING_MODEL" in exc_info.value.suggestion
assert "ANTHROPIC_TOOLCALL_MODEL" in exc_info.value.suggestion
def test_non_anthropic_model_not_found_maps_to_generic_opensre_error() -> None:
"""A 'model not found' error from a non-Anthropic provider uses the generic 404 guidance."""
exc = RuntimeError("OpenAI model 'gpt-99' was not found. Check your configuration.")
with pytest.raises(OpenSREError) as exc_info:
reraise_cli_runtime_error(exc)
assert "not found" in str(exc_info.value).lower()
assert exc_info.value.suggestion is not None
assert "ANTHROPIC_REASONING_MODEL" not in exc_info.value.suggestion
def test_cli_not_found_still_maps_correctly() -> None:
"""Existing CLI-not-found branch must still work after the new branch was added."""
exc = RuntimeError("CLI not found on path: codex")
with pytest.raises(OpenSREError) as exc_info:
reraise_cli_runtime_error(exc)
assert "CLI tool is not installed" in str(exc_info.value)
def test_runtime_prompt_too_long_with_unclear_auth_maps_to_opensre_error() -> None:
exc = RuntimeError(
"cursor agent exited with code 1. prompt too long — shorten the input or reduce "
"accumulated context (/context to inspect)\n\nAuth status could not be verified "
"before invocation. Run: agent login."
)
with pytest.raises(OpenSREError) as exc_info:
reraise_cli_runtime_error(exc)
err = exc_info.value
assert str(err) == "LLM invocation failed."
assert err.suggestion is not None
assert "prompt too long" in err.suggestion
assert "Auth status could not be verified before invocation" in err.suggestion
def test_cli_timeout_maps_to_opensre_error() -> None:
exc = CLITimeoutError("gemini-cli CLI timed out after 300s.")
with pytest.raises(OpenSREError) as exc_info:
reraise_cli_runtime_error(exc)
err = exc_info.value
assert "timed out" in str(err).lower()
assert err.suggestion is not None
assert "GEMINI_CLI_TIMEOUT_SECONDS" in err.suggestion
def test_bedrock_model_not_available_maps_to_opensre_error() -> None:
exc = RuntimeError(
"Bedrock model 'us.anthropic.claude-sonnet-4-6' is not available for your account. "
"Check Bedrock model access in the configured AWS region, AWS Marketplace "
"subscription/payment setup, and IAM permissions including "
"aws-marketplace:ViewSubscriptions and aws-marketplace:Subscribe."
)
with pytest.raises(OpenSREError) as exc_info:
reraise_cli_runtime_error(exc)
err = exc_info.value
assert "Bedrock model" in str(err)
assert err.suggestion is not None
assert "AWS Marketplace" in err.suggestion
assert "aws-marketplace:ViewSubscriptions" in err.suggestion
assert "aws-marketplace:Subscribe" in err.suggestion