Environment Variable Validation/Error Handling
This commit is contained in:
@@ -68,13 +68,17 @@ class SecureApiCall:
|
||||
if not env_name.replace("_", "").isalnum():
|
||||
raise ValueError("Environment variable names must only contain letters, numbers, and underscores")
|
||||
env_var = f"COMFYUI_SECUREAPICALL_{env_name}"
|
||||
api_url = os.getenv(env_var) or raise ValueError(f"Environment Variable {env_var} is not set")
|
||||
api_url = os.getenv(env_var)
|
||||
if not api_url:
|
||||
raise ValueError(f"Environment Variable {env_var} is not set")
|
||||
if api_auth.startswith("$ENV."):
|
||||
env_name = api_auth.removeprefix("$ENV.")
|
||||
if not env_name.replace("_", "").isalnum():
|
||||
raise ValueError("Environment variable names must only contain letters, numbers, and underscores")
|
||||
env_var = f"COMFYUI_SECUREAPICALL_{env_name}"
|
||||
api_auth = os.getenv(env_var) or raise ValueError(f"Environment Variable {env_var} is not set")
|
||||
api_auth = os.getenv(env_var)
|
||||
if not api_auth:
|
||||
raise ValueError(f"Environment Variable {env_var} is not set")
|
||||
|
||||
# Send the payload to the API
|
||||
res = requests.post(
|
||||
|
||||
Reference in New Issue
Block a user