Comfy-Org/ComfyUI · error · ValueError
folder_name must name a subfolder of the datasets directory,
Error message
folder_name must name a subfolder of the datasets directory, e.g. 'my_dataset'.
What it means
get_dataset_save_dir resolves the requested folder inside the first configured datasets root and then rejects the degenerate case where the resolved target equals the root itself. A folder_name of '' or '.' resolves to the root, and saving a dataset 'into the root' would scatter its files among all other datasets, so the function demands a real subfolder name.
Source
Thrown at comfy_extras/nodes_dataset.py:122
child_key = (child_st.st_dev, child_st.st_ino)
if child_key not in seen_dirs:
kept_subdirs.append(name)
subdirs[:] = kept_subdirs
return sorted(found)
def get_dataset_save_dir(folder_name):
"""Resolve the folder to save a new dataset into, inside the default root.
The folder is not created here; callers makedirs after validation.
"""
root = folder_paths.get_folder_paths("datasets")[0]
target = secure_subfolder_path(root, folder_name)
if os.path.realpath(target) == os.path.realpath(root):
raise ValueError("folder_name must name a subfolder of the datasets directory, e.g. 'my_dataset'.")
return target
def get_dataset_dir(folder_name):
"""Find an existing dataset folder by relative name across all dataset roots."""
roots = folder_paths.get_folder_paths("datasets")
for root in roots:
target = secure_subfolder_path(root, folder_name)
if os.path.realpath(target) == os.path.realpath(root):
raise ValueError("folder_name must name a subfolder of the datasets directory, e.g. 'my_dataset'.")
if os.path.isdir(target):
return target
raise ValueError(f"Dataset folder {folder_name!r} not found in: {', '.join(roots)}")
VALID_VIDEO_EXTENSIONS = [".mp4", ".avi", ".mov", ".webm", ".mkv", ".flv"]
View on GitHub (pinned to 1c6d8d45b3)
Solutions
- Provide a concrete subfolder name, e.g. 'my_new_dataset'.
- Default the widget value in the frontend or upstream logic so it is never empty.
- Trim slashes: 'my_dataset/' is fine but '' or '.' is not.
Example fix
# before folder_name = "" # after folder_name = "my_dataset"
Defensive patterns
Strategy: validation
Validate before calling
def concrete_folder_name(name: str) -> str:
name = (name or "").strip().strip("/")
if not name or name == ".":
raise ValueError("folder_name must be a subfolder name")
return name Type guard
def is_concrete_name(name) -> bool:
return isinstance(name, str) and name.strip().strip("/") not in ("", ".") Prevention
- Give the folder widget a non-empty default.
- Trim trailing slashes and reject '.'/'..' in adapters.
- Offer choices from list_dataset_folders() in the UI.
When it happens
Trigger: Calling the save-dir resolver with folder_name = '', '.', or any name that realpath-normalizes to the datasets root (e.g. 'sub/../' on some filesystems). Note this fires after secure_subfolder_path, so traversal names hit the earlier containment error instead.
Common situations: An empty string widget value reaching the node; string manipulation upstream that strips the folder name to nothing; users leaving the folder field blank expecting a default.
Related errors
- Dataset folder {folder_name!r} not found in: {', '.join(root
- Expected 4D image tensor, got shape {tuple(images.shape)}
- INVALID_TAG_FILTER
- Connect at least one keyframe image.
- Spreading {len(images)} images across the clip needs an expl
AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14).
Data as JSON: /api/errors/77d0936cfd5d7635.
Report an issue: GitHub.