From 0f2b1115c5a9f3861e05cee363361a08f61d8f27 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Wed, 12 Nov 2025 09:44:45 +0000 Subject: [PATCH 1/2] fix invalid token error message --- nodes/common.py | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/nodes/common.py b/nodes/common.py index 890997f..49ee9af 100644 --- a/nodes/common.py +++ b/nodes/common.py @@ -8,6 +8,14 @@ import requests import time import json + +COMFY_KEY_ERROR = ( + "Invalid Token Type\n\n" + "The API token you’ve entered is not a ComfyUI token.\n" + "Please use the valid token from your BRIA Account API Keys page:\n" + "https://platform.bria.ai/console/account/api-keys" +) + def postprocess_image(image): result_image = Image.open(io.BytesIO(image)) result_image = result_image.convert("RGB") @@ -148,14 +156,20 @@ def poll_status_until_completed(status_url, api_key, timeout=360, check_interval raise Exception(f"Timeout reached after {timeout} seconds") -def deserialize_and_get_comfy_key(encoded: str): +def deserialize_and_get_comfy_key(encoded: str) -> str: + """ + Decodes a base64-encoded JSON token and returns the ComfyUI API key. + """ try: decoded = base64.b64decode(encoded).decode("utf-8") payload = json.loads(decoded) - if (payload['type'] == "comfy"): - return payload['apiKey'] - else: - raise Exception(f"Invalid token type") + + if payload.get("type") != "comfy": + raise Exception(COMFY_KEY_ERROR) + + return payload.get("apiKey") + except Exception as e: - raise Exception(f"Invalid token") + raise Exception(COMFY_KEY_ERROR) + From b5d4d41bb823b6cd7d38088c60323439146a6d56 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Wed, 12 Nov 2025 12:03:13 +0000 Subject: [PATCH 2/2] update version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 5e34640..dc1cd58 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "comfyui-bria-api" description = "Custom nodes for ComfyUI using BRIA's API." -version = "2.1.6" +version = "2.1.7" license = {file = "LICENSE"} [project.urls]