Comfy-Org / Comfy-Org/ComfyUI

[BUG] secure_subfolder_path raises ValueError when --output-directory is set to a UNC network path

Open Beginner friendly
#16,086 0 comments 0 reactions 0 assignees View on GitHub
Potential Bug
Dominant language
Python
Stars
133k
Forks
15.7k
Avg merge
1d 6h
Merged PRs (30d)
155

Description

### Custom Node Testing

- [x] I have tried disabling custom nodes and the issue persists (see [how to disable custom nodes](https://docs.comfy.org/troubleshooting/custom-node-issues#step-1%3A-test-with-all-custom-nodes-disabled) if you need help)

### Expected Behavior

When launched with a UNC path (e.g., --output-directory "\\\nas\temp_fast"), nodes that save to subfolders (such as Save Image-Text (to Folder) [BETA]) should resolve subfolder destinations within the network share and save files successfully without raising path validation errors.

See attached "ComfyUI_LocalDrive.log" which saves without issue to a local drive.

### Actual Behavior

Nodes using secure_subfolder_path fail with ValueError: Invalid folder name 'dataset': resolves outside of \\\nas\temp_fast when --output-directory is specified using UNC pathing.

The standard Save Image node saves to the share without issue, and Save Image-Text (to Folder) [BETA] works fine when --output-directory is pointed to a local drive letter (e.g., D:\temp_fast).

See attached "ComfyUI_NetworkDrive.log".

### Steps to Reproduce

1. Launch ComfyUI passing a UNC network share path via command line: .\python_embeded\python.exe -s ComfyUI\main.py --windows-standalone-build --output-directory "\\\nas\temp_fast" --disable-all-custom-nodes
2. Open the UI and load a workflow using the built-in Save Image-Text (to Folder) [BETA] node (from comfy_extras/nodes_dataset.py) configured to write to a subfolder (e.g., dataset).
3. Queue the prompt.
4. Execution fails during subfolder path validation in nodes_dataset.py.

### Debug Logs

```powershell
D:\AI\ComfyUI_windows_portable>.\python_embeded\python.exe -s ComfyUI\main.py --windows-standalone-build --output-directory "\\nas\temp_fast" --disable-all-custom-nodes
←[32m[INFO]←[0m setup plugin alembic.autogenerate.schemas
←[32m[INFO]←[0m setup plugin alembic.autogenerate.tables
←[32m[INFO]←[0m setup plugin alembic.autogenerate.types
←[32m[INFO]←[0m setup plugin alembic.autogenerate.constraints
←[32m[INFO]←[0m setup plugin alembic.autogenerate.defaults
←[32m[INFO]←[0m setup plugin alembic.autogenerate.comments
←[32m[INFO]←[0m setup plugin alembic.autogenerate.checkconstraint_byname
[WARNING] On windows we are currently forcing single GPU mode in ComfyUI due to a Nvidia related issue, if you want to disable this use: --cuda-device all
[INFO] Setting output directory to: \\nas\temp_fast
[INFO] Found comfy_kitchen backend triton: {'available': True, 'disabled': True, 'unavailable_reason': None, 'capabilities': ['adaln', 'apply_rope', 'apply_rope1', 'apply_rope1_', 'apply_rope_', 'apply_rope_split_half', 'apply_rope_split_half1', 'apply_rope_split_half1_', 'apply_rope_split_half_', 'dequantize_nvfp4', 'dequantize_per_tensor_fp8', 'int8_linear', 'na3d', 'quantize_and_rotate_rowwise', 'quantize_int8_rowwise', 'quantize_mxfp8', 'quantize_nvfp4', 'quantize_per_tensor_fp8', 'rms_adaln', 'rms_rope', 'rms_rope1', 'rms_rope1_', 'rms_rope_', 'rms_rope_split_half', 'rms_rope_split_half1', 'rms_rope_split_half1_', 'rms_rope_split_half_', 'w4a8_int8_linear']}
[INFO] Found comfy_kitchen backend cuda: {'available': True, 'disabled': False, 'unavailable_reason': None, 'capabilities': ['adaln', 'apply_rope', 'apply_rope1', 'apply_rope1_', 'apply_rope_', 'apply_rope_split_half', 'apply_rope_split_half1', 'apply_rope_split_half1_', 'apply_rope_split_half_', 'convrot_w4a4_linear', 'dequantize_convrot_w4a4_weight', 'dequantize_int8_convrot_weight', 'dequantize_int8_convrot_weight_dtype', 'dequantize_int8_simple', 'dequantize_int8_simple_dtype', 'dequantize_nvfp4', 'dequantize_per_tensor_fp8', 'dequantize_w4a8_int8_weight', 'gemv_awq_w4a16', 'int8_linear', 'na3d', 'prepare_int4_weight_for_int8_linear', 'quantize_and_rotate_rowwise', 'quantize_convrot_w4a4_weight', 'quantize_int8_convrot_weight', 'quantize_int8_rowwise', 'quantize_int8_tensorwise', 'quantize_mxfp8', 'quantize_nvfp4', 'quantize_per_tensor_fp8', 'quantize_svdquant_w4a4', 'quantize_w4a8_int8_weight', 'rms_adaln', 'rms_rope', 'rms_rope1', 'rms_rope1_', 'rms_rope_', 'rms_rope_split_half', 'rms_rope_split_half1', 'rms_rope_split_half1_', 'rms_rope_split_half_', 'rotate_int8_convrot_weight', 'scaled_mm_nvfp4', 'scaled_mm_svdquant_w4a4', 'stochastic_rounding_fp8', 'w4a8_int8_linear']}
[INFO] Found comfy_kitchen backend eager: {'available': True, 'disabled': False, 'unavailable_reason': None, 'capabilities': ['adaln', 'apply_rope', 'apply_rope1', 'apply_rope1_', 'apply_rope_', 'apply_rope_split_half', 'apply_rope_split_half1', 'apply_rope_split_half1_', 'apply_rope_split_half_', 'convrot_w4a4_linear', 'dequantize_convrot_w4a4_weight', 'dequantize_int8_convrot_weight', 'dequantize_int8_convrot_weight_dtype', 'dequantize_int8_embedding', 'dequantize_int8_simple', 'dequantize_int8_simple_dtype', 'dequantize_mxfp8', 'dequantize_nvfp4', 'dequantize_per_tensor_fp8', 'dequantize_w4a8_int8_weight', 'gemv_awq_w4a16', 'int8_linear', 'na3d', 'prepare_int4_weight_for_int8_linear', 'quantize_and_rotate_rowwise', 'quantize_convrot_w4a4_weight', 'quantize_int8_convrot_weight', 'quantize_int8_rowwise', 'quantize_int8_tensorwise', 'quantize_mxfp8', 'quantize_nvfp4', 'quantize_per_tensor_fp8', 'quantize_svdquant_w4a4', 'quantize_w4a8_int8_weight', 'rms_adaln', 'rms_rope', 'rms_rope1', 'rms_rope1_', 'rms_rope_', 'rms_rope_split_half', 'rms_rope_split_half1', 'rms_rope_split_half1_', 'rms_rope_split_half_', 'rotate_int8_convrot_weight', 'scaled_mm_mxfp8', 'scaled_mm_nvfp4', 'scaled_mm_svdquant_w4a4', 'stochastic_rounding_fp8', 'w4a8_int8_linear']}
[INFO] Found comfy_kitchen backend hip: {'available': False, 'disabled': False, 'unavailable_reason': 'PyTorch ROCm/HIP runtime not available', 'capabilities': []}
[INFO] Checkpoint files will always be loaded safely.
[INFO] Total VRAM 16275 MB, total RAM 62885 MB
[INFO] pytorch version: 2.13.0+cu130
[INFO] Set vram state to: NORMAL_VRAM
[INFO] Device: cuda:0 NVIDIA GeForce RTX 5070 Ti : cudaMallocAsync
[INFO] Using async weight offloading with 2 streams
[INFO] Enabled pinned memory 25154.0
[INFO] Using pytorch attention
[INFO] aimdo: src-win/cuda-detour.c:38:INFO:aimdo_setup_hooks: installing 6 hooks
[INFO] aimdo: src/control.c:262:INFO:comfy-aimdo NVML pressure enabled
[INFO] aimdo: src-win/shmem-detect.c:80:INFO:comfy-aimdo WDDM adapter match: NVIDIA GeForce RTX 5070 Ti runtime_luid=00000000:0000cdc2 dxgi_luid=00000000:0000cdc2
[INFO] aimdo: src/control.c:277:INFO:comfy-aimdo inited for GPU: NVIDIA GeForce RTX 5070 Ti (VRAM: 16275 MB)
[INFO] DynamicVRAM support detected and enabled
[INFO] Python version: 3.13.14 (tags/v3.13.14:fd17997, Jun 10 2026, 13:03:48) [MSC v.1944 64 bit (AMD64)]
[INFO] ComfyUI version: 0.34.0
[INFO] comfy-aimdo version: 0.4.15
[INFO] comfy-kitchen version: 0.2.31
[INFO] comfyui-frontend-package version: 1.51.9
[INFO] comfyui-workflow-templates version: 0.11.54
[INFO] comfyui-embedded-docs version: 0.5.10
[INFO] comfy-kitchen version: 0.2.31
[INFO] comfy-aimdo version: 0.4.15
[INFO] [Prompt Server] web root: D:\AI\ComfyUI_windows_portable\python_embeded\Lib\site-packages\comfyui_frontend_package\static
[INFO] Asset seeder disabled
[INFO] No OpenGL_accelerate module loaded: No module named 'OpenGL_accelerate'
[INFO] Skipping loading of custom nodes
[INFO] Context impl SQLiteImpl.
[INFO] Will assume non-transactional DDL.
[INFO] Using RAM pressure cache.
[INFO] Starting server

[INFO] To see the GUI go to: http://127.0.0.1:8188
[ERROR] Exception in callback _ProactorBasePipeTransport._call_connection_lost()
handle:
Traceback (most recent call last):
File "asyncio\events.py", line 89, in _run
File "asyncio\proactor_events.py", line 165, in _call_connection_lost
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
[INFO] got prompt
[INFO] Using pytorch attention in VAE
[INFO] Using pytorch attention in VAE
[INFO] VAE load device: cuda:0, offload device: cpu, dtype: torch.bfloat16
[INFO] Found quantization metadata version 1
[INFO] Using MixedPrecisionOps for text encoder
[INFO] CLIP/text encoder model load device: cuda:0, offload device: cpu, current: cpu, dtype: torch.float16
[INFO] Requested to load ZImageTEModel_
[INFO] Model ZImageTEModel_ prepared for dynamic VRAM loading. 3317MB Staged. 0 patches attached. Force pre-loaded 145 weights: 383 KB.
[INFO] Model ZImageTEModel_ prepared for dynamic VRAM loading. 3317MB Staged. 0 patches attached. Force pre-loaded 145 weights: 383 KB.
[INFO] Found quantization metadata version 1
[INFO] Detected mixed precision quantization
[INFO] Using mixed precision operations
[INFO] Native ops: nvfp4, int8_tensorwise, convrot_w4a4, float8_e4m3fn, mxfp8, float8_e5m2, asym_w4a8_int8
[INFO] model weight dtype torch.bfloat16, manual cast: torch.bfloat16
[INFO] model_type FLOW
[INFO] Requested to load Lumina2
[INFO] Model Lumina2 prepared for dynamic VRAM loading. 4299MB Staged. 0 patches attached. Force pre-loaded 385 weights: 1046 KB.
100%|████████████████████████████████████████████████████████████████████████████████████| 8/8 [00:02<00:00, 3.64it/s]
[INFO] Requested to load AutoencodingEngine
[INFO] Model AutoencodingEngine prepared for dynamic VRAM loading. 159MB Staged. 0 patches attached. Force pre-loaded 108 weights: 182 KB.
[INFO] Prompt executed in 6.13 seconds
[INFO] got prompt
[ERROR] !!! Exception during processing !!! Invalid folder name 'dataset': resolves outside of \\nas\temp_fast
[ERROR] Traceback (most recent call last):
File "D:\AI\ComfyUI_windows_portable\ComfyUI\execution.py", line 545, in execute
output_data, output_ui, has_subgraph, has_pending_tasks = await get_output_data(prompt_id, unique_id, obj, input_data_all, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb, v3_data=v3_data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\AI\ComfyUI_windows_portable\ComfyUI\execution.py", line 344, in get_output_data
return_values = await _async_map_node_over_list(prompt_id, unique_id, obj, input_data_all, obj.FUNCTION, allow_interrupt=True, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb, v3_data=v3_data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\AI\ComfyUI_windows_portable\ComfyUI\execution.py", line 312, in _async_map_node_over_list
await process_inputs(input_data_all, 0, input_is_list=input_is_list)
File "D:\AI\ComfyUI_windows_portable\ComfyUI\execution.py", line 306, in process_inputs
result = f(**inputs)
File "D:\AI\ComfyUI_windows_portable\ComfyUI\comfy_api\internal\__init__.py", line 149, in wrapped_func
return method(locked_class, **inputs)
File "D:\AI\ComfyUI_windows_portable\ComfyUI\comfy_api\latest\_io.py", line 2046, in EXECUTE_NORMALIZED
to_return = cls.execute(*args, **kwargs)
File "D:\AI\ComfyUI_windows_portable\ComfyUI\comfy_extras\nodes_dataset.py", line 544, in execute
output_dir = secure_subfolder_path(folder_paths.get_output_directory(), folder_name)
File "D:\AI\ComfyUI_windows_portable\ComfyUI\comfy_extras\nodes_dataset.py", line 54, in secure_subfolder_path
raise ValueError(f"Invalid folder name {folder_name!r}: resolves outside of {base_dir}")
ValueError: Invalid folder name 'dataset': resolves outside of \\nas\temp_fast

[INFO] Prompt executed in 0.01 seconds
[INFO]
Stopped server
```

### Other

[ComfyUI_LocalDrive.log](https://github.com/user-attachments/files/31828378/ComfyUI_LocalDrive.log)
[ComfyUI_NetworkDrive.log](https://github.com/user-attachments/files/31828379/ComfyUI_NetworkDrive.log)
[Default Workflow Save Image to Folder.json](https://github.com/user-attachments/files/31828429/Default.Workflow.Save.Image.to.Folder.json)
[Default Workflow Save Image.json](https://github.com/user-attachments/files/31828428/Default.Workflow.Save.Image.json)

**Startup Commands Used:**
.\python_embeded\python.exe -s ComfyUI\main.py --windows-standalone-build --output-directory "D:\temp_fast" --disable-all-custom-nodes
.\python_embeded\python.exe -s ComfyUI\main.py --windows-standalone-build --output-directory "\\\nas\temp_fast" --disable-all-custom-nodes

Contributor guide

Open the contributing guide

Research direction

Start in comfy_extras/nodes_dataset.py at secure_subfolder_path and its call from the Save Image-Text (to Folder) node; reproduce the failure with the supplied UNC --output-directory command. Confirm that a subfolder such as dataset validates and saves successfully on the UNC share while the existing local-drive behavior continues to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.