Comfy-Org/ComfyUI · error · ValueError

Unknown strategy

Error message

Unknown strategy: {strategy}

What it means

Thrown by the video frame-sampling node when the 'strategy' input is neither 'uniform' nor 'random'. The node dispatches on an if/elif chain over the strategy string and treats anything else as a programming/validation error. In practice only a mismatched frontend enum, a hand-edited workflow JSON, or a custom node sending a raw string reaches it.

Solutions

  1. Set strategy to 'uniform' (evenly spaced frames) or 'random' (seeded random selection).
  2. Open the node in the ComfyUI UI and re-pick the strategy from the dropdown, then re-save the workflow.
  3. If you are generating the prompt programmatically, validate strategy against ['uniform','random'] before queueing.

Example fix

// before (workflow JSON)
"inputs": { "strategy": "evenly", ... }
// after
"inputs": { "strategy": "uniform", ... }
Defensive patterns

Strategy: validation

Validate before calling

VALID_STRATEGIES = {'uniform', 'random'}
assert strategy in VALID_STRATEGIES, f'strategy must be one of {sorted(VALID_STRATEGIES)}, got {strategy!r}'

Type guard

def is_valid_strategy(s: str) -> bool:
    return s in {'uniform', 'random'}

Prevention

When it happens

Trigger: Calling the node with strategy set to a value outside {'uniform','random'}: e.g. a workflow file saved with 'evenly', 'stride', or a typo like 'unifrom', or a script constructing the prompt dict with an arbitrary strategy string.

Common situations: Hand-edited or LLM-generated workflow JSON with a wrong enum value; workflows migrated from another sampler node whose strategy names differ ('first', 'last', 'evenly'); custom frontends that do not enforce the combo options.

Related errors


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

Appendix: source

Thrown at comfy_extras/nodes_dataset.py:1266

            return io.NodeOutput(
                video.as_trimmed(0.0, num_frames / fps, strict_duration=False)
            )
        if strategy == "tail":
            start_t = (total_frames - num_frames) / fps
            return io.NodeOutput(
                video.as_trimmed(start_t, num_frames / fps, strict_duration=False)
            )

        if strategy == "uniform":
            if num_frames == 1:
                indices = [total_frames // 2]
            else:
                indices = [round(i * (total_frames - 1) / (num_frames - 1)) for i in range(num_frames)]
        elif strategy == "random":
            rng = np.random.RandomState(seed % (2**32 - 1))
            indices = sorted(rng.choice(total_frames, size=num_frames, replace=False).tolist())
        else:
            raise ValueError(f"Unknown strategy: {strategy}")

        return io.NodeOutput(_decode_selected_frames(video, indices))


class VideoTemporalCropNode(io.ComfyNode):
    """Crop a continuous range of frames from a video (fully lazy)."""

    @classmethod
    def define_schema(cls):
        return io.Schema(
            node_id="VideoTemporalCrop",
            search_aliases=["crop", "crop video", "temporal crop", "truncate video"],
            display_name="Crop Video (Temporal)",
            category="video/transform",
            description="Crop a continuous range of frames from a video.",
            is_experimental=True,
            inputs=[
                io.Video.Input("video", tooltip="Input video."),

View on GitHub (pinned to 1c6d8d45b3)