fix: ignore stale pro features (glossary/prompt) from frontend localstorage for free users instead of blocking translations
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 2m17s
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 2m17s
This commit is contained in:
@@ -532,6 +532,13 @@ async def translate_document_v1(
|
||||
if prompt_id in ("null", "undefined", ""): prompt_id = None
|
||||
if file_url in ("null", "undefined", ""): file_url = None
|
||||
|
||||
# Story 3.12 / Bugfix: If user is on the free tier, they might have stale Pro features
|
||||
# in their frontend localStorage (e.g., they downgraded, or switched accounts).
|
||||
# Instead of hard-blocking the translation, we simply strip the Pro features.
|
||||
if tier == "free":
|
||||
glossary_id = None
|
||||
custom_prompt = None
|
||||
prompt_id = None
|
||||
|
||||
if file_url:
|
||||
if tier == "free":
|
||||
@@ -541,14 +548,6 @@ async def translate_document_v1(
|
||||
details={"feature": "file_url", "tier": tier},
|
||||
)
|
||||
|
||||
# Story 3.12: Include prompt_id in Pro feature check
|
||||
if (glossary_id or custom_prompt or prompt_id) and tier == "free":
|
||||
raise TranslateEndpointError(
|
||||
code=TranslateEndpointError.PRO_FEATURE_REQUIRED,
|
||||
message="Glossaries and custom prompts are reserved for Pro users.",
|
||||
details={"feature": "glossary_id, custom_prompt, or prompt_id", "tier": tier},
|
||||
)
|
||||
|
||||
# Story 3.10: Validate glossary access before creating the job
|
||||
if glossary_id and user_id:
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user