fix: disable silent google cloud fallback to expose true provider errors
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 2s

This commit is contained in:
2026-05-17 17:25:00 +02:00
parent b50419e2ec
commit 63aeb5978d

View File

@@ -992,11 +992,9 @@ async def _run_translation_job(
translation_provider = None
_p = provider.lower()
# "google" (default classic mode): use Google Cloud API key if available,
# otherwise fall back to deep_translator (legacy, no key).
# When the Cloud API key IS present, wrap it in a fallback so that
# quota / network errors don't kill the job — deep_translator is tried
# as a best-effort second chance.
# "google" (default classic mode): use Google Cloud API key if available.
# We no longer fall back silently to the free legacy translator if the Cloud API fails.
# If the key is invalid or quota is exceeded, we want the error to bubble up to the user.
if _p == "google":
# the user might have set GOOGLE_API_KEY instead of GOOGLE_CLOUD_API_KEY
gc_key = _cfg(
@@ -1006,14 +1004,11 @@ async def _run_translation_job(
if gc_key:
from services.providers.google_cloud_provider import LegacyGoogleCloudAdapter
from services.translation_service import GoogleTranslationProvider
cloud_adapter = LegacyGoogleCloudAdapter(gc_key)
legacy_fallback = GoogleTranslationProvider()
translation_provider = _GoogleCloudWithFallback(
cloud_adapter, legacy_fallback
)
logger.info("google_provider_using_cloud_api_with_fallback", job_id=job_id)
translation_provider = LegacyGoogleCloudAdapter(gc_key)
logger.info("google_provider_using_cloud_api", job_id=job_id)
else:
from services.translation_service import GoogleTranslationProvider
translation_provider = GoogleTranslationProvider()
logger.info("google_provider_no_cloud_key_using_legacy", job_id=job_id)
elif _p in ("openrouter", "llm") and api_key: