Comfy-Org/ComfyUI · error · ValueError

INVALID_QUERY

INVALID_QUERY

Error message

metadata_filter must be JSON: {e}

What it means

Raised by LatentBlend.blend_mode when the blend_mode string passed to LatentBlend.blend is anything other than "normal". The blend method's Python signature accepts any string (blend_mode: str = "normal") and the UI combo does not enumerate the extra modes, so this guard exists to reject values the implementation never handles. The node only implements the "normal" blend (which simply returns img2 before the factor mix).

Source

Thrown at app/assets/api/schemas_in.py:105

            return [t.strip() for t in v.split(",") if t.strip()]
        if isinstance(v, list):
            out: list[str] = []
            for item in v:
                if isinstance(item, str):
                    out.extend([t.strip() for t in item.split(",") if t.strip()])
            return out
        return v

    @field_validator("metadata_filter", mode="before")
    @classmethod
    def _parse_metadata_json(cls, v):
        if v is None or isinstance(v, dict):
            return v
        if isinstance(v, str) and v.strip():
            try:
                parsed = json.loads(v)
            except Exception as e:
                raise ValueError(f"metadata_filter must be JSON: {e}") from e
            if not isinstance(parsed, dict):
                raise ValueError("metadata_filter must be a JSON object")
            return parsed
        return None


class UpdateAssetBody(BaseModel):
    name: str | None = None
    user_metadata: dict[str, Any] | None = None
    preview_id: str | None = None  # references an asset_reference id, not an asset id

    @model_validator(mode="after")
    def _validate_at_least_one_field(self):
        if all(
            v is None
            for v in (self.name, self.user_metadata, self.preview_id)
        ):
            raise ValueError(

View on GitHub (pinned to 1c6d8d45b3)

Solutions

  1. Omit blend_mode entirely (it defaults to "normal") or set it to exactly "normal" — lowercase, exact match.
  2. If you need other blend behaviors, implement them yourself on the LATENT tensors before/after LatentBlend, or use a dedicated compositing node.
  3. Audit API prompts and custom frontends for hardcoded blend_mode strings and remove or correct them.

Example fix

# before
result = latent_blend.blend(samples1, samples2, 0.5, blend_mode="multiply")

# after
result = latent_blend.blend(samples1, samples2, 0.5)  # blend_mode defaults to "normal"
Defensive patterns

Strategy: validation

Validate before calling

SUPPORTED_BLEND_MODES = {"normal"}

def blend_mode_ok(mode: str) -> bool:
    return mode in SUPPORTED_BLEND_MODES

Type guard

def is_supported_blend_mode(mode: str) -> bool:
    return isinstance(mode, str) and mode == "normal"

Try / catch

try:
    out = latent_blend.blend(samples1, samples2, blend_factor, blend_mode)
except ValueError as e:
    if "Unsupported blend mode" in str(e):
        out = latent_blend.blend(samples1, samples2, blend_factor)  # fall back to "normal"
    else:
        raise

Prevention

When it happens

Trigger: Calling LatentBlend.blend programmatically (API prompt or custom node) with blend_mode set to e.g. "multiply", "screen", or any non-default string; a saved workflow or frontend extension exposing blend-mode options that the node implementation does not support; typos like "Normal" (case-sensitive check).

Common situations: Custom scripts building API prompts that assume image-editor blend modes exist on the latent blend node; third-party UI extensions adding a blend-mode dropdown with unsupported values; porting workflows between forks where LatentBlend gained modes but upstream never did.

Related errors


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