{"record":{"id":"0eac95dfc5d21c9f","repo":"invoke-ai/InvokeAI","slug":"could-not-read-text-encoder-config-json-e","errorCode":null,"errorMessage":"could not read text_encoder/config.json: {e}","messagePattern":"could not read text_encoder/config\\.json: (.+?)","errorType":"validation","errorClass":"NotAMatchError","httpStatus":null,"severity":"error","filePath":"invokeai/backend/model_manager/configs/qwen_vl_encoder.py","lineNumber":102,"sourceCode":"            )\n\n        text_encoder_dir = mod.path / \"text_encoder\"\n        tokenizer_dir = mod.path / \"tokenizer\"\n\n        if not text_encoder_dir.is_dir():\n            raise NotAMatchError(\"missing text_encoder/ subfolder\")\n        if not tokenizer_dir.is_dir():\n            raise NotAMatchError(\"missing tokenizer/ subfolder\")\n\n        config_path = text_encoder_dir / \"config.json\"\n        if not config_path.is_file():\n            raise NotAMatchError(f\"missing {config_path}\")\n\n        try:\n            with open(config_path, \"r\", encoding=\"utf-8\") as f:\n                cfg = json.load(f)\n        except (OSError, json.JSONDecodeError) as e:\n            raise NotAMatchError(f\"could not read text_encoder/config.json: {e}\") from e\n\n        class_name = cfg.get(\"_class_name\")\n        architectures = cfg.get(\"architectures\") or []\n        candidates = {class_name, *architectures} - {None}\n\n        if not candidates & _RECOGNIZED_TEXT_ENCODER_CLASSES:\n            raise NotAMatchError(\n                f\"text_encoder class is {sorted(candidates) or 'unknown'}, \"\n                f\"expected one of {sorted(_RECOGNIZED_TEXT_ENCODER_CLASSES)}\"\n            )\n\n        return cls(**override_fields)\n\n\nclass QwenVLEncoder_Checkpoint_Config(Checkpoint_Config_Base, Config_Base):\n    \"\"\"Configuration for single-file Qwen2.5-VL encoder checkpoints (safetensors).\n\n    This matches ComfyUI-style consolidated single-file encoders such as","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/model_manager/configs/qwen_vl_encoder.py#L84-L120","documentation":"`NotAMatchError` `could not read text_encoder/config.json: {e}` means the config file exists but could not be opened or parsed — an `OSError` (permissions, unreadable file, path issue) or a `json.JSONDecodeError` (truncated/corrupt/invalid JSON). The loader chains the underlying exception so `__cause__` holds the real reason.","triggerScenarios":"`from_model_on_disk` (invoked via model probing) on a model whose `text_encoder/config.json` is unreadable: zero-byte file from an interrupted download, HTML error page saved as config.json, permission-denied, or truncated write.","commonSituations":"Interrupted or disk-full downloads, files synced before upload finished (cloud-drive placeholders), non-UTF8 or hand-edited JSON with trailing commas, files locked by another process on network shares.","solutions":["Inspect `error.__cause__` to see whether it is an OSError or JSONDecodeError","Validate the file: `python -c \"import json;print(json.load(open('text_encoder/config.json')))\"`","Re-download `text_encoder/config.json` from the source HF repo","Fix file permissions (`chmod 644`) or move the model off a failing network mount"],"exampleFix":"# before: truncated / corrupt config.json\n# after\nhuggingface-cli download <repo> text_encoder/config.json --force-download","handlingStrategy":"validation","validationCode":"import json\nfrom pathlib import Path\n\ndef config_json_parses(model_dir: Path) -> bool:\n    p = model_dir / \"text_encoder\" / \"config.json\"\n    try:\n        json.loads(p.read_text(encoding=\"utf-8\"))\n        return True\n    except (OSError, json.JSONDecodeError):\n        return False","typeGuard":null,"tryCatchPattern":"try:\n    cfg = QwenVLTextEncoderConfig.from_model_on_disk(mod, override_fields)\nexcept NotAMatchError as e:\n    cause = e.__cause__\n    print(f\"config.json unreadable: {cause!r}\")  # OSError vs JSONDecodeError tells you the fix\n    raise","preventionTips":["Validate JSON after download: `python -m json.tool config.json`","Compare file size/permissions against the source repo","Avoid hand-editing model config files; re-fetch them instead","Watch for cloud-sync placeholder files before loading models"],"tags":["model-install","json","corrupt-file"],"backgroundTag":"invalid-json-config","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}