From 5149de0556589f8c0a574a1579b6adc531cdf2ed Mon Sep 17 00:00:00 2001 From: pyr0ball Date: Mon, 20 Apr 2026 10:50:49 -0700 Subject: [PATCH] fix(text): fail fast on empty --model instead of crashing in backend Add early validation in create_app(): raise ValueError with a clear message when model_path is empty and mock=False. Prevents the cryptic HFValidationError that surfaced when cf-orch passed an empty {model} arg (cf-orch #46). Surfaces the real problem at the service layer rather than deep inside the HuggingFace loader. --- circuitforge_core/text/app.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/circuitforge_core/text/app.py b/circuitforge_core/text/app.py index 7f78078..b2759cb 100644 --- a/circuitforge_core/text/app.py +++ b/circuitforge_core/text/app.py @@ -116,6 +116,12 @@ def create_app( ) -> FastAPI: global _backend + if not mock and not model_path: + raise ValueError( + "cf-text: --model is required (got empty string). " + "Pass a GGUF path, a HuggingFace model ID, or set CF_TEXT_MOCK=1 for mock mode." + ) + os.environ.setdefault("CUDA_VISIBLE_DEVICES", str(gpu_id)) _backend = make_text_backend(model_path, backend=backend, mock=mock)