{"record":{"id":"20e6d9d4a461fe24","repo":"Comfy-Org/ComfyUI","slug":"cannot-convert-type-type-value-name-to-cls","errorCode":null,"errorMessage":"Cannot convert type {type(value).__name__} to {cls.__name__} enum. Expected string, None, or {cls.__name__} instance.","messagePattern":"Cannot convert type (.+?) to (.+?) enum\\. Expected string, None, or (.+?) instance\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"comfy/ldm/lightricks/vae/causal_audio_autoencoder.py","lineNumber":69,"sourceCode":"                # Handle members with None values\n                if member.value is None:\n                    if value_lower == \"none\":\n                        return member\n                # Handle members with string values\n                elif isinstance(member.value, str) and member.value.lower() == value_lower:\n                    return member\n\n            # Build helpful error message with valid values\n            valid_values = []\n            for member in cls:\n                if member.value is None:\n                    valid_values.append(\"none\")\n                elif isinstance(member.value, str):\n                    valid_values.append(member.value)\n\n            raise ValueError(f\"Invalid {cls.__name__} string: '{value}'. \" f\"Valid values are: {valid_values}\")\n\n        raise ValueError(\n            f\"Cannot convert type {type(value).__name__} to {cls.__name__} enum. \"\n            f\"Expected string, None, or {cls.__name__} instance.\"\n        )\n\n\nclass AttentionType(StringConvertibleEnum):\n    \"\"\"Enum for specifying the attention mechanism type.\"\"\"\n\n    VANILLA = \"vanilla\"\n    LINEAR = \"linear\"\n    NONE = \"none\"\n\n\nclass CausalityAxis(StringConvertibleEnum):\n    \"\"\"Enum for specifying the causality axis in causal convolutions.\"\"\"\n\n    NONE = None\n    WIDTH = \"width\"","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy/ldm/lightricks/vae/causal_audio_autoencoder.py#L51-L87","documentation":"Raised by StringConvertibleEnum when the value passed is neither an instance of the enum, None, nor a str — for example an int, bool, or list. The enum coercion only supports string, None, and enum instances; anything else has no defined conversion.","triggerScenarios":"Passing a non-string scalar to an enum-typed parameter, e.g. CausalityAxis(0), AttentionType(1), or AttentionType(True); often happens when configs use integer codes from a different schema.","commonSituations":"Configs migrated from integer-indexed enums in other codebases; programmatic config generation that emits ints; booleans intended as flags passed to enum fields.","solutions":["Convert the value to its string name before passing (str(value) if it names a member)","Look up the enum member by whatever mapping your config uses and pass that member","If integer codes are required upstream, map them explicitly: {0: AttentionType.VANILLA, ...}[code]"],"exampleFix":"# before\nattn_type = 0  # from an int-indexed config\nmake_attention(in_channels, attn_type=attn_type)\n\n# after\nINT_TO_ATTN = {0: AttentionType.VANILLA, 1: AttentionType.LINEAR, 2: AttentionType.NONE}\nmake_attention(in_channels, attn_type=INT_TO_ATTN[attn_type])","handlingStrategy":"type-guard","validationCode":"if not isinstance(attn_type, (str, AttentionType)) and attn_type is not None:\n    raise TypeError(f\"expected str, None, or AttentionType, got {type(attn_type).__name__}\")","typeGuard":"def is_enum_convertible(cls, v) -> bool:\n    return isinstance(v, (cls, str)) or v is None","tryCatchPattern":null,"preventionTips":["Type-annotate enum-typed parameters and check isinstance at config boundaries","Map integer config codes to enum members explicitly instead of passing raw ints"],"tags":["enum","type-error","validation","audio-vae"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}