From 7bb8df73afa865a78cad8618854878b89fa21b17 Mon Sep 17 00:00:00 2001 From: velaraptor-runpod Date: Thu, 30 Apr 2026 20:37:30 -0500 Subject: [PATCH] bug: fix hf-token being passed in engineargs --- src/engine_args.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/engine_args.py b/src/engine_args.py index 8ed132c..f6d92d9 100644 --- a/src/engine_args.py +++ b/src/engine_args.py @@ -82,6 +82,16 @@ def _convert_env_value_to_field_type(value: str, field_name: str, field_type: ty if type(None) in (args or ()): return None raise ValueError("empty value not allowed for non-optional field") + + # Union[bool, str, ...]: only coerce to bool for unambiguous literals; + # otherwise preserve the string (e.g. hf_token="hf_abc..." must stay a str). + if get_origin(field_type) is not None: + union_types = [a for a in (get_args(field_type) or ()) if a is not type(None)] + if bool in union_types and str in union_types: + if str(val).lower() in ("true", "false", "1", "0", "yes", "no", "on", "off"): + return str(val).lower() in ("true", "1", "yes", "on") + return str(val) + effective_type = _resolve_field_type(field_type) # bool if effective_type is bool: