{"record":{"id":"318ab745edb98d11","repo":"invoke-ai/InvokeAI","slug":"error-scanning-the-model-at-path-for-malware-ab","errorCode":null,"errorMessage":"Error scanning the model at {path} for malware. Aborting import.","messagePattern":"Error scanning the model at (.+?) for malware\\. Aborting import\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"invokeai/backend/model_manager/util/model_util.py","lineNumber":80,"sourceCode":"    else:\n        if scan:\n            scan_result = pscan.scan_file_path(path)\n            if scan_result.infected_files != 0:\n                if get_config().unsafe_disable_picklescan:\n                    logger.warning(\n                        f\"The model {path} is potentially infected by malware, but picklescan is disabled. \"\n                        \"Proceeding with caution.\"\n                    )\n                else:\n                    raise RuntimeError(f\"The model {path} is potentially infected by malware. Aborting import.\")\n            if scan_result.scan_err:\n                if get_config().unsafe_disable_picklescan:\n                    logger.warning(\n                        f\"Error scanning the model at {path} for malware, but picklescan is disabled. \"\n                        \"Proceeding with caution.\"\n                    )\n                else:\n                    raise RuntimeError(f\"Error scanning the model at {path} for malware. Aborting import.\")\n\n        checkpoint = torch.load(path, map_location=torch.device(\"meta\"))\n    return checkpoint\n\n\ndef lora_token_vector_length(checkpoint: dict[str | int, torch.Tensor]) -> Optional[int]:\n    \"\"\"\n    Given a checkpoint in memory, return the lora token vector length\n\n    :param checkpoint: The checkpoint\n    \"\"\"\n\n    def _get_shape_1(key: str, tensor: torch.Tensor, checkpoint: dict[str | int, torch.Tensor]) -> Optional[int]:\n        lora_token_vector_length = None\n\n        if \".\" not in key:\n            return lora_token_vector_length  # wrong key format\n        model_key, lora_key = key.split(\".\", 1)","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/model_manager/util/model_util.py#L62-L98","documentation":"read_checkpoint_meta() treats a picklescan error (scan_result.scan_err) — meaning the scan itself failed and safety is unknown — as fatal. Unless picklescan is disabled via config, the import is aborted with this RuntimeError.","triggerScenarios":"picklescan raises or returns scan_err=True while scanning a checkpoint during import, e.g. on malformed, encrypted, or unusually structured pickles, or when picklescan encounters an opcode it cannot analyze.","commonSituations":"Corrupted or truncated downloads; checkpoints saved with exotic pickle protocols or non-standard serialization; picklescan version incompatibilities with new torch pickle formats.","solutions":["Re-download the model (file may be corrupt) and retry the scan.","Run picklescan manually (picklescan --path file.ckpt) to see the underlying scan error.","Upgrade/downgrade picklescan to a version compatible with the file.","If the source is trusted and the scan is a known false failure, set unsafe_disable_picklescan=true in config."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"from picklescan.scanner import scan_file_path\ntry:\n    r = scan_file_path(model_file)\n    if r.scan_err:\n        print(f'picklescan could not analyze {model_file}: investigate before import')\nexcept Exception as e:\n    print(f'scan failed: {e}')","typeGuard":null,"tryCatchPattern":"try:\n    ckpt = read_checkpoint_meta(path)\nexcept RuntimeError as e:\n    if 'Error scanning the model' in str(e):\n        run_picklescan_manually(path)  # diagnose; re-download if corrupt\n    else:\n        raise","preventionTips":["Verify file integrity (checksum) after download to rule out corruption.","Keep picklescan and torch versions current so new pickle formats are understood.","Diagnose with `picklescan --path file.ckpt` before retrying import."],"tags":["security","pickle","scan-failure"],"backgroundTag":"pickle-scan-error","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}