{"record":{"id":"b5abe2ddc9adcd54","repo":"invoke-ai/InvokeAI","slug":"algorithm-algorithm-not-available","errorCode":null,"errorMessage":"Algorithm {algorithm} not available","messagePattern":"Algorithm (.+?) not available","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"invokeai/backend/model_hash/model_hash.py","lineNumber":76,"sourceCode":"        # MD5\n        ModelHash(\"md5\").hash(\"path/to/model/dir/\") # \"md5:a0cd925fc063f98dbf029eee315060c3\"\n        ```\n    \"\"\"\n\n    def __init__(\n        self, algorithm: HASHING_ALGORITHMS = \"blake3_single\", file_filter: Optional[Callable[[str], bool]] = None\n    ) -> None:\n        self.algorithm: HASHING_ALGORITHMS = algorithm\n        if algorithm == \"blake3_multi\":\n            self._hash_file = self._blake3\n        elif algorithm == \"blake3_single\":\n            self._hash_file = self._blake3_single\n        elif algorithm in hashlib.algorithms_available:\n            self._hash_file = self._get_hashlib(algorithm)\n        elif algorithm == \"random\":\n            self._hash_file = self._random\n        else:\n            raise ValueError(f\"Algorithm {algorithm} not available\")\n\n        self._file_filter = file_filter or self._default_file_filter\n\n    def hash(self, model_path: Union[str, Path]) -> str:\n        \"\"\"\n        Return hexdigest of hash of model located at model_path using the algorithm provided at class instantiation.\n\n        If model_path is a directory, the hash is computed by hashing the hashes of all model files in the\n        directory. The final composite hash is always computed using BLAKE3.\n\n        Args:\n            model_path: Path to the model\n\n        Returns:\n            str: Hexdigest of the hash of the model\n        \"\"\"\n\n        model_path = Path(model_path)","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/model_hash/model_hash.py#L58-L94","documentation":"ModelHash.__init__ raises ValueError when the requested algorithm is not 'blake3', not in hashlib.algorithms_available, and not the literal 'random'. InvokeAI only supports a fixed set of hashing algorithms for model identification.","triggerScenarios":"Constructing ModelHash(algorithm='xyz') where 'xyz' is a typo, an unsupported name (e.g. 'blake2' variant not linked into hashlib), or a hash name unavailable in the running Python build (some OpenSSL builds lack certain algorithms).","commonSituations":"Typo like 'sha1 ' with a trailing space or 'blake3s'; running on a Python/OpenSSL build where the algorithm isn't compiled in; config file carrying an algorithm name from a different tool (e.g. 'sha3-256' is fine, but 'sha3_256' naming mismatches fail).","solutions":["Use a supported value: 'blake3', 'random', or any name in hashlib.algorithms_available (e.g. 'md5', 'sha1', 'sha256', 'sha512').","Print sorted(hashlib.algorithms_available) to confirm the exact spelling your Python build accepts.","If the algorithm is genuinely missing (e.g. blake3 variants beyond single), install the blake3 extra or pick an available hashlib algorithm."],"exampleFix":"// before\nhasher = ModelHash('blake3-multi')\n// after\nhasher = ModelHash('blake3')  # or 'sha256', 'random', etc.","handlingStrategy":"validation","validationCode":"from invokeai.backend.model_hash.model_hash import ModelHash\n\ndef algorithm_is_supported(algorithm: str) -> bool:\n    return algorithm in ('blake3', 'random') or algorithm in __import__('hashlib').algorithms_available","typeGuard":"def is_valid_algorithm(a: object) -> TypeGuard[str]:\n    import hashlib\n    return isinstance(a, str) and (a in ('blake3', 'random') or a in hashlib.algorithms_available)","tryCatchPattern":"try:\n    hasher = ModelHash(algorithm)\nexcept ValueError as e:\n    logger.error(f'Unsupported hash algorithm: {e}; falling back to blake3')\n    hasher = ModelHash('blake3')","preventionTips":["Always use 'blake3' (the InvokeAI default) unless you have a specific reason not to.","Check hashlib.algorithms_available on the target runtime before configuring a custom algorithm.","Keep algorithm names in config files as constants, not free-form strings."],"tags":["invokeai","configuration","hash","valueerror"],"backgroundTag":"invalid-argument-value","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}