invoke-ai/InvokeAI · error · RuntimeError
Error scanning the model at {path} for malware. Aborting imp
Error message
Error scanning the model at {path} for malware. Aborting import. What it means
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.
Source
Thrown at invokeai/backend/model_manager/util/model_util.py:80
else:
if scan:
scan_result = pscan.scan_file_path(path)
if scan_result.infected_files != 0:
if get_config().unsafe_disable_picklescan:
logger.warning(
f"The model {path} is potentially infected by malware, but picklescan is disabled. "
"Proceeding with caution."
)
else:
raise RuntimeError(f"The model {path} is potentially infected by malware. Aborting import.")
if scan_result.scan_err:
if get_config().unsafe_disable_picklescan:
logger.warning(
f"Error scanning the model at {path} for malware, but picklescan is disabled. "
"Proceeding with caution."
)
else:
raise RuntimeError(f"Error scanning the model at {path} for malware. Aborting import.")
checkpoint = torch.load(path, map_location=torch.device("meta"))
return checkpoint
def lora_token_vector_length(checkpoint: dict[str | int, torch.Tensor]) -> Optional[int]:
"""
Given a checkpoint in memory, return the lora token vector length
:param checkpoint: The checkpoint
"""
def _get_shape_1(key: str, tensor: torch.Tensor, checkpoint: dict[str | int, torch.Tensor]) -> Optional[int]:
lora_token_vector_length = None
if "." not in key:
return lora_token_vector_length # wrong key format
model_key, lora_key = key.split(".", 1)View on GitHub (pinned to 0b6a024f2f)
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.
Defensive patterns
Strategy: try-catch
Validate before calling
from picklescan.scanner import scan_file_path
try:
r = scan_file_path(model_file)
if r.scan_err:
print(f'picklescan could not analyze {model_file}: investigate before import')
except Exception as e:
print(f'scan failed: {e}') Try / catch
try:
ckpt = read_checkpoint_meta(path)
except RuntimeError as e:
if 'Error scanning the model' in str(e):
run_picklescan_manually(path) # diagnose; re-download if corrupt
else:
raise Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Corrupted or truncated downloads; checkpoints saved with exotic pickle protocols or non-standard serialization; picklescan version incompatibilities with new torch pickle formats.
Related errors
- The model {path.stem} is potentially infected by malware. Ab
- Error scanning the model at {path.stem} for malware. Abortin
- The model {path} is potentially infected by malware. Abortin
- only relative download paths accepted
- Cannot derive a safe filename for {url} from '{file_name}'
AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29).
Data as JSON: /api/errors/318ab745edb98d11.
Report an issue: GitHub.