{"record":{"id":"5b6e11f956bef9fd","repo":"chroma-core/chroma","slug":"invalid-hash-algorithm-specified-alg","errorCode":null,"errorMessage":"Invalid hash algorithm specified: {alg}","messagePattern":"Invalid hash algorithm specified: (.+?)","errorType":"exception","errorClass":"InvalidHashError","httpStatus":null,"severity":"error","filePath":"chromadb/db/migrations.py","lineNumber":267,"sourceCode":"\ndef _read_migration_file(file: MigrationFile, hash_alg: str) -> Migration:\n    \"\"\"Read a migration file\"\"\"\n    if \"path\" not in file or not file[\"path\"].is_file():\n        raise FileNotFoundError(\n            f\"No migration file found for dir {file['dir']} with filename {file['filename']} and scope {file['scope']} at version {file['version']}\"\n        )\n    sql = file[\"path\"].read_text()\n\n    if hash_alg == \"md5\":\n        hash = (\n            hashlib.md5(sql.encode(\"utf-8\"), usedforsecurity=False).hexdigest()\n            if sys.version_info >= (3, 9)\n            else hashlib.md5(sql.encode(\"utf-8\")).hexdigest()\n        )\n    elif hash_alg == \"sha256\":\n        hash = hashlib.sha256(sql.encode(\"utf-8\")).hexdigest()\n    else:\n        raise InvalidHashError(alg=hash_alg)\n\n    return {\n        \"hash\": hash,\n        \"sql\": sql,\n        \"dir\": file[\"dir\"],\n        \"filename\": file[\"filename\"],\n        \"version\": file[\"version\"],\n        \"scope\": file[\"scope\"],\n    }\n","sourceCodeStart":249,"sourceCodeEnd":277,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/chromadb/db/migrations.py#L249-L277","documentation":"Raised by _read_migration_file when the hash_alg argument is neither 'md5' nor 'sha256' (chromadb/db/migrations.py:267) — InvalidHashError. It guards the config value that decides how migration SQL is hashed for consistency checks, and fires before any SQL is read or applied.","triggerScenarios":"Passing a migrations hash-algorithm setting/parameter with an unsupported value (anything other than the exact strings 'md5' or 'sha256', including case variants like 'MD5' or 'SHA-256'). This is plumbed through migration configuration internals, not the public client API.","commonSituations":"Custom deployments or forks that expose hash algorithm config and set it to 'sha512'/'sha-256'/uppercase variants; copy-pasted config snippets; code written against a newer/older Chroma that accepted different algorithm names.","solutions":["Set the value to exactly 'md5' or 'sha256' (lowercase, no separators).","If you wrote the config plumbing yourself, validate the setting at startup against the allowed set rather than letting it fail deep in migration loading.","Upgrade Chroma if you expect a newer algorithm to be supported."],"exampleFix":"# before\nfind_migrations(dir, scope, hash_alg=\"sha-256\")  # InvalidHashError\n\n# after\nfind_migrations(dir, scope, hash_alg=\"sha256\")","handlingStrategy":"validation","validationCode":"assert hash_alg in (\"md5\", \"sha256\"), f\"Unsupported hash_alg: {hash_alg}\"","typeGuard":null,"tryCatchPattern":"from chromadb.db.migrations import InvalidHashError\ntry:\n    find_migrations(dir, scope, hash_alg=alg)\nexcept InvalidHashError:\n    alg = \"md5\"\n    find_migrations(dir, scope, hash_alg=alg)","preventionTips":["Restrict hash-alg config to the literal strings 'md5' or 'sha256'.","Validate custom config at startup, not deep in migration loading.","Cover config values with tests when you fork/extend migration settings."],"tags":["chroma","migrations","config","hash","invalid-value"],"backgroundTag":"invalid-config-value","analyzedSha":"aecdd12c8a891610db8653630b066b32ceb678b5","analyzedAt":"2026-08-16T21:53:27.228Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}