{"id":"712dcb8ff5646c02","repo":"sqlalchemy/alembic","slug":"no-such-revision-or-branch-s-s","errorCode":null,"errorMessage":"No such revision or branch '%s'%s","messagePattern":"No such revision or branch '(.+?)'(.+?)","errorType":"exception","errorClass":"ResolutionError","httpStatus":null,"severity":"error","filePath":"alembic/script/revision.py","lineNumber":630,"sourceCode":"        try:\n            revision = self._revision_map[resolved_id]\n        except KeyError:\n            # break out to avoid misleading py3k stack traces\n            revision = False\n        revs: Sequence[str]\n        if revision is False:\n            assert resolved_id\n            # do a partial lookup\n            revs = [\n                x\n                for x in self._revision_map\n                if x and len(x) > 3 and x.startswith(resolved_id)\n            ]\n\n            if branch_rev:\n                revs = self.filter_for_lineage(revs, check_branch)\n            if not revs:\n                raise ResolutionError(\n                    \"No such revision or branch '%s'%s\"\n                    % (\n                        resolved_id,\n                        (\n                            \"; please ensure at least four characters are \"\n                            \"present for partial revision identifier matches\"\n                            if len(resolved_id) < 4\n                            else \"\"\n                        ),\n                    ),\n                    resolved_id,\n                )\n            elif len(revs) > 1:\n                raise ResolutionError(\n                    \"Multiple revisions start \"\n                    \"with '%s': %s...\"\n                    % (resolved_id, \", \".join(\"'%s'\" % r for r in revs[0:3])),\n                    resolved_id,","sourceCodeStart":612,"sourceCodeEnd":648,"githubUrl":"https://github.com/sqlalchemy/alembic/blob/44fb3450330204b222ff05135e1fbbbdb28c44db/alembic/script/revision.py#L612-L648","documentation":"Raised by _revision_for_ident when a (possibly partial) identifier matches zero revisions in the map. Partial identifiers must be at least 4 characters long; the message appends a hint about this when the input is shorter. It is a ResolutionError.","triggerScenarios":"Passing a revision id that does not exist; a partial prefix shorter than 4 chars; a partial prefix of >= 4 chars that no revision starts with; a down_revision pointing at a deleted migration.","commonSituations":"Referencing a revision that was renamed or removed; stale cookie/cached revision id in a deploy tool; checkout mismatch where the migration file exists in one branch but not the current one; typo in a downgrade target.","solutions":["Run 'alembic history' or script.walk_revisions() to confirm the exact revision id.","If using a partial prefix, supply at least 4 characters and ensure it is unique.","If a migration was deleted, restore it or fix the down_revision/depends_on pointers that reference it.","Make sure the script directory location (script_location config) points at the right folder."],"exampleFix":"# before\nalembic downgrade abc          # < 4 chars, no match\n# after\nalembic downgrade abc12345def  # full or >=4-char unique prefix","handlingStrategy":"validation","validationCode":"all_ids = {r.revision for r in script.walk_revisions()}\nif target not in all_ids and not any(\n    rid.startswith(target) for rid in all_ids if len(target) >= 4\n):\n    raise ValueError('unknown revision: %s' % target)","typeGuard":null,"tryCatchPattern":"from alembic.script.revision import ResolutionError\ntry:\n    rev = script.get_revision(target)\nexcept ResolutionError as e:\n    # unknown/ambiguous id; log and fall back\n    ...","preventionTips":["Always pass full revision ids in automation.","If using prefixes, ensure >= 4 characters and uniqueness.","Validate ids against the script directory before issuing commands."],"tags":["revision-resolution","partial-id","alembic"],"analyzedSha":"44fb3450330204b222ff05135e1fbbbdb28c44db","analyzedAt":"2026-08-04T19:57:10.248Z","schemaVersion":2}