Comfy-Org/ComfyUI · error · ValueError

Unknown context_schedule '{context_schedule}'.

Error message

Unknown context_schedule '{context_schedule}'.

What it means

get_matching_context_schedule maps a schedule-name string to a window-creation function via CONTEXT_MAPPING, which only contains the ContextSchedules enum values (UNIFORM_LOOPED, UNIFORM_STANDARD, STATIC_STANDARD, BATCHED). Any other string raises ValueError with the offending name quoted — this is strict enum-style validation of user/node input.

Source

Thrown at comfy/context_windows.py:930

    return windows


def create_windows_default(num_frames: int, handler: IndexListContextHandler):
    return [list(range(num_frames))]


CONTEXT_MAPPING = {
    ContextSchedules.UNIFORM_LOOPED: create_windows_uniform_looped,
    ContextSchedules.UNIFORM_STANDARD: create_windows_uniform_standard,
    ContextSchedules.STATIC_STANDARD: create_windows_static_standard,
    ContextSchedules.BATCHED: create_windows_batched,
}


def get_matching_context_schedule(context_schedule: str) -> ContextSchedule:
    func = CONTEXT_MAPPING.get(context_schedule, None)
    if func is None:
        raise ValueError(f"Unknown context_schedule '{context_schedule}'.")
    return ContextSchedule(context_schedule, func)


def get_context_weights(length: int, full_length: int, idxs: list[int], handler: IndexListContextHandler, sigma: torch.Tensor=None, context_overlap: int=None):
    context_overlap = handler.context_overlap if context_overlap is None else context_overlap
    return handler.fuse_method.func(length, sigma=sigma, handler=handler, full_length=full_length, idxs=idxs, context_overlap=context_overlap)


def create_weights_flat(length: int, **kwargs) -> list[float]:
    # weight is the same for all
    return [1.0] * length

def create_weights_pyramid(length: int, **kwargs) -> list[float]:
    # weight is based on the distance away from the edge of the context window;
    # based on weighted average concept in FreeNoise paper
    if length % 2 == 0:
        max_weight = length // 2
        weight_sequence = list(range(1, max_weight + 1, 1)) + list(range(max_weight, 0, -1))

View on GitHub (pinned to 1c6d8d45b3)

Solutions

  1. Use one of the exact values: check ContextSchedules in comfy/context_windows.py and pass e.g. ContextSchedules.UNIFORM_STANDARD.
  2. Expose schedule selection as a combo of the enum values in your node rather than free text.
  3. Validate/normalize user input against list(CONTEXT_MAPPING) before calling.

Example fix

# before
get_matching_context_schedule("uniform_loop")

# after
from comfy.context_windows import ContextSchedules, get_matching_context_schedule
get_matching_context_schedule(ContextSchedules.UNIFORM_LOOPED)
Defensive patterns

Strategy: validation

Validate before calling

from comfy.context_windows import CONTEXT_MAPPING
if context_schedule not in CONTEXT_MAPPING:
    raise SystemExit(f"unknown schedule; valid: {list(CONTEXT_MAPPING)}")
sched = get_matching_context_schedule(context_schedule)

Type guard

from comfy.context_windows import CONTEXT_MAPPING
def is_valid_schedule(name: str) -> bool:
    return name in CONTEXT_MAPPING

Try / catch

try:
    sched = get_matching_context_schedule(name)
except ValueError:
    name = "uniform_standard"  # safe default
    sched = get_matching_context_schedule(name)

Prevention

When it happens

Trigger: A node or workflow passes a schedule string not in the enum (typos like 'uniform_loop' or 'standard'); custom nodes hardcoding schedule names from an older/newer ComfyUI where the enum differs; dynamically-built prompts injecting arbitrary strings.

Common situations: Version drift after enum values were added/renamed; workflows saved with a custom node's schedule names; spaces or case differences ('Uniform Looped').

Related errors


AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14). Data as JSON: /api/errors/efd2d4215710a153. Report an issue: GitHub.