diff --git a/json_loader_dynamic.py b/json_loader_dynamic.py index e275735..8a10b02 100644 --- a/json_loader_dynamic.py +++ b/json_loader_dynamic.py @@ -63,6 +63,8 @@ if PromptServer is not None: seq = 1 data = read_json_data(json_path) target = get_batch_item(data, seq) + if not data: + return web.json_response({"keys": [], "types": [], "error": "file_not_found"}) keys = [] types = [] if isinstance(target, dict): diff --git a/pyproject.toml b/pyproject.toml index 1e5ab8a..499145a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "comfyui-json-dynamic" -version = "1.2.0" +version = "1.2.1" description = "ComfyUI nodes for dynamic JSON loading and string/path utility operations" license = { file = "LICENSE" } requires-python = ">=3.10" diff --git a/web/json_dynamic.js b/web/json_dynamic.js index 7073bba..df7b70a 100644 --- a/web/json_dynamic.js +++ b/web/json_dynamic.js @@ -39,7 +39,14 @@ app.registerExtension({ const resp = await api.fetchApi( `/json_dynamic/get_keys?path=${encodeURIComponent(pathWidget.value)}&sequence_number=${seqWidget?.value || 1}` ); - const { keys, types } = await resp.json(); + const data = await resp.json(); + const { keys, types } = data; + + // If the file wasn't found, keep existing outputs and links intact + if (data.error === "file_not_found") { + console.warn("[JSONDynamicLoader] File not found, keeping existing outputs:", pathWidget.value); + return; + } // Store keys and types in hidden widgets for persistence const okWidget = this.widgets?.find(w => w.name === "output_keys");