mirror of
https://github.com/lfnovo/open-notebook.git
synced 2026-12-05 14:04:08 +00:00
* fix: error hints, Italian menu entry and dev fallbacks found by the docs review - error_classifier: read timeouts get their own message naming ESPERANTO_LLM_TIMEOUT; connect failures keep "Could not connect". Auth hint points to Manage -> Models; provision's "Please go to Manage" message is recognized again. - Podcast voice hint and the empty-episodes text point to real screens. - LanguageToggle renders the registered languages list, so it-IT shows up (and future locales can't be missed); it-IT date locale added. The per-language common.* labels it used are removed. - make start-all uses the shipped compose file. - Legacy SURREAL_ADDRESS/SURREAL_PORT fallback builds ws://host:port/rpc. - .env.example uses the real OPEN_NOTEBOOK_CHUNK_* names. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: address review (IPv6 legacy address, connection-timed-out wording, stronger tests) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test: assert exception class for OS connection timeouts Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
60 lines
1.9 KiB
Python
60 lines
1.9 KiB
Python
"""classify_error() tells a slow provider apart from an unreachable one."""
|
|
|
|
import httpx
|
|
|
|
from open_notebook.exceptions import (
|
|
AuthenticationError,
|
|
ConfigurationError,
|
|
NetworkError,
|
|
)
|
|
from open_notebook.utils.error_classifier import classify_error
|
|
|
|
|
|
def test_read_timeout_says_the_provider_was_slow():
|
|
exc_class, message = classify_error(
|
|
httpx.ReadTimeout("The read operation timed out")
|
|
)
|
|
assert exc_class is NetworkError
|
|
assert "took too long" in message
|
|
assert "ESPERANTO_LLM_TIMEOUT" in message
|
|
|
|
|
|
def test_openai_style_timeout_says_the_provider_was_slow():
|
|
class APITimeoutError(Exception):
|
|
pass
|
|
|
|
_, message = classify_error(APITimeoutError("Request timed out."))
|
|
assert "took too long" in message
|
|
|
|
|
|
def test_connect_timeout_is_a_connection_problem():
|
|
exc_class, message = classify_error(httpx.ConnectTimeout("timed out"))
|
|
assert exc_class is NetworkError
|
|
assert "Could not connect" in message
|
|
|
|
|
|
def test_connection_refused_is_a_connection_problem():
|
|
exc_class, message = classify_error(
|
|
httpx.ConnectError("[Errno 111] Connection refused")
|
|
)
|
|
assert exc_class is NetworkError
|
|
assert "Could not connect" in message
|
|
|
|
|
|
def test_os_connection_timed_out_is_a_connection_problem():
|
|
exc_class, message = classify_error(OSError("[Errno 110] Connection timed out"))
|
|
assert exc_class is NetworkError
|
|
assert "Could not connect" in message
|
|
|
|
|
|
def test_auth_error_points_to_the_models_page():
|
|
exc_class, message = classify_error(Exception("401 invalid api key"))
|
|
assert exc_class is AuthenticationError
|
|
assert "Manage -> Models" in message
|
|
|
|
|
|
def test_missing_default_model_passes_through():
|
|
raw = "No model configured for default for type=chat. Please go to Manage → Models and configure a default model for 'chat'."
|
|
exc_class, message = classify_error(ValueError(raw))
|
|
assert exc_class is ConfigurationError
|
|
assert message == raw
|