mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
Normalize FAL_KEY env handling (ignore whitespace-only values)
Treat whitespace-only FAL_KEY the same as unset so users who export FAL_KEY=" " (or CI that leaves a blank token) get the expected 'not set' error path instead of a confusing downstream fal_client failure. Applied to the two direct FAL_KEY checks in image_generation_tool.py: image_generate_tool's upfront credential check and check_fal_api_key(). Both keep the existing managed-gateway fallback intact. Adapted the original whitespace/valid tests to pin the managed gateway to None so the whitespace assertion exercises the direct-key path rather than silently relying on gateway absence.
This commit is contained in:
parent
5e6427a42c
commit
77061ac995
2 changed files with 45 additions and 2 deletions
|
|
@ -623,7 +623,9 @@ def image_generate_tool(
|
|||
if not prompt or not isinstance(prompt, str) or len(prompt.strip()) == 0:
|
||||
raise ValueError("Prompt is required and must be a non-empty string")
|
||||
|
||||
if not (os.getenv("FAL_KEY") or _resolve_managed_fal_gateway()):
|
||||
fal_key_value = os.getenv("FAL_KEY")
|
||||
fal_key_set = bool(fal_key_value and fal_key_value.strip())
|
||||
if not (fal_key_set or _resolve_managed_fal_gateway()):
|
||||
message = "FAL_KEY environment variable not set"
|
||||
if managed_nous_tools_enabled():
|
||||
message += " and managed FAL gateway is unavailable"
|
||||
|
|
@ -734,7 +736,9 @@ def image_generate_tool(
|
|||
|
||||
def check_fal_api_key() -> bool:
|
||||
"""True if the FAL.ai API key (direct or managed gateway) is available."""
|
||||
return bool(os.getenv("FAL_KEY") or _resolve_managed_fal_gateway())
|
||||
fal_key_value = os.getenv("FAL_KEY")
|
||||
fal_key_set = bool(fal_key_value and fal_key_value.strip())
|
||||
return bool(fal_key_set or _resolve_managed_fal_gateway())
|
||||
|
||||
|
||||
def check_image_generation_requirements() -> bool:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue