{"record":{"id":"24d2215b4c501293","repo":"Comfy-Org/ComfyUI","slug":"response-validation-failed-for-getattr-response-m","errorCode":null,"errorMessage":"Response validation failed for {getattr(response_model, '__name__', response_model)}: {e}","messagePattern":"Response validation failed for (.+?): (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"comfy_api_nodes/util/client.py","lineNumber":981,"sourceCode":"                        else int(time.monotonic() - start_time)\n                    ),\n                    estimated_total=cfg.estimated_total,\n                    price=extracted_price,\n                    is_queued=False,\n                    processing_elapsed_seconds=final_elapsed_seconds,\n                )\n\n\ndef _validate_or_raise(response_model: type[M], payload: Any) -> M:\n    try:\n        return response_model.model_validate(payload)\n    except Exception as e:\n        logging.error(\n            \"Response validation failed for %s: %s\",\n            getattr(response_model, \"__name__\", response_model),\n            e,\n        )\n        raise Exception(\n            f\"Response validation failed for {getattr(response_model, '__name__', response_model)}: {e}\"\n        ) from e\n\n\ndef _wrap_model_extractor(\n    response_model: type[M],\n    extractor: Callable[[M], Any] | None,\n) -> Callable[[dict[str, Any]], Any] | None:\n    \"\"\"Wrap a typed extractor so it can be used by the dict-based poller.\n    Validates the dict into `response_model` before invoking `extractor`.\n    Uses a small per-wrapper cache keyed by `id(dict)` to avoid re-validating\n    the same response for multiple extractors in a single poll attempt.\n    \"\"\"\n    if extractor is None:\n        return None\n    _cache: dict[int, M] = {}\n\n    def _wrapped(d: dict[str, Any]) -> Any:","sourceCodeStart":963,"sourceCodeEnd":999,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy_api_nodes/util/client.py#L963-L999","documentation":"A remote API response body failed Pydantic validation against the expected response model. The helper _validate_or_raise calls response_model.model_validate(payload) and re-raises as a generic Exception when the payload does not satisfy the model's schema. This almost always means the upstream service returned a different shape than the node's Pydantic model declares (renamed/missing fields, changed types, or an error payload returned with HTTP 200).","triggerScenarios":"Any Comfy API-node request whose response is validated by _validate_or_raise in comfy_api_nodes/util/client.py: an upstream API ships a schema change (field renamed, null where a string was required, nested object flattened), or the service returns an HTML/JSON error document with a 200 status that does not match the model.","commonSituations":"Upstream provider deploys a breaking API change; API version pinned in the node no longer matches the live endpoint; a proxy or firewall rewrites the response body; the response model in the local ComfyUI install is older/newer than the API contract.","solutions":["Read the logged validation detail (the message includes the Pydantic error, e.g. 'Field required', 'Input should be a valid integer') to identify the exact field mismatch.","Check the provider's API changelog / openapi spec for the failing endpoint and compare against the Pydantic model named in the message.","Update ComfyUI (and comfy_api_nodes) to the latest version, which usually tracks the current API schema.","If you maintain the node, adjust the response model (make the field Optional, add a default, or rename it) to match the observed payload, keeping validation strict for the rest of the schema."],"exampleFix":"// before\nclass GenerationResponse(BaseModel):\n    video_url: str  # upstream renamed to output.video_url\n\n// after\nclass GenerationOutput(BaseModel):\n    video_url: str\n\nclass GenerationResponse(BaseModel):\n    output: GenerationOutput | None = None\n    video_url: str | None = None\n    @property\n    def resolved_video_url(self) -> str:\n        return self.video_url or (self.output.video_url if self.output else \"\")","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    result = await node_api.call(...)\nexcept Exception as e:\n    if 'Response validation failed' in str(e):\n        # log raw payload via request_logger, then surface a clear message\n        raise RuntimeError(f'API schema mismatch: {e}') from e\n    raise","preventionTips":["Keep ComfyUI and comfy_api_nodes updated so response models track the live API.","When adding nodes, make optional API fields Optional with defaults instead of required.","Log the raw response body at debug level so schema mismatches are diagnosable."],"tags":["pydantic","validation","api-schema","comfy-api-nodes"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}