{"id":"2f501a41c005ecd5","repo":"sqlalchemy/alembic","slug":"requested-revision-s-overlaps-with-other-requeste","errorCode":null,"errorMessage":"Requested revision %s overlaps with other requested revisions %s","messagePattern":"Requested revision (.+?) overlaps with other requested revisions (.+?)","errorType":"exception","errorClass":"RevisionError","httpStatus":null,"severity":"error","filePath":"alembic/script/revision.py","lineNumber":910,"sourceCode":"                if rev in seen:\n                    continue\n                seen.add(rev)\n                # Check for map errors before collecting.\n                for rev_id in fn(rev):\n                    next_rev = map_[rev_id]\n                    assert next_rev is not None\n                    if next_rev.revision != rev_id:\n                        raise RevisionError(\n                            \"Dependency resolution failed; broken map\"\n                        )\n                    todo.append(next_rev)\n                yield rev\n            if check:\n                overlaps = per_target.intersection(targets).difference(\n                    [target]\n                )\n                if overlaps:\n                    raise RevisionError(\n                        \"Requested revision %s overlaps with \"\n                        \"other requested revisions %s\"\n                        % (\n                            target.revision,\n                            \", \".join(r.revision for r in overlaps),\n                        )\n                    )\n\n    def _topological_sort(\n        self,\n        revisions: Collection[Revision],\n        heads: Any,\n    ) -> list[str]:\n        \"\"\"Yield revision ids of a collection of Revision objects in\n        topological sorted order (i.e. revisions always come after their\n        down_revisions and dependencies). Uses the order of keys in\n        _revision_map to sort.\n","sourceCodeStart":892,"sourceCodeEnd":928,"githubUrl":"https://github.com/sqlalchemy/alembic/blob/44fb3450330204b222ff05135e1fbbbdb28c44db/alembic/script/revision.py#L892-L928","documentation":"Raised inside _iterate_related_revisions when called with check=True and the set of target revisions overlap each other in the traversal (one target is an ancestor/dependent of another within the same requested set). This guards against asking for revisions whose lineages are not independent. It is a RevisionError.","triggerScenarios":"Calling internal APIs that pass overlapping revision sets with the check flag (e.g., certain _shares_lineage / _get_descendant_nodes paths used during upgrade/downgrade planning); requesting two targets where one depends on the other.","commonSituations":"Custom migration planners that pass overlapping revision sets; rarely surfaced from standard CLI usage.","solutions":["Dedupe and de-overlap the requested revision set before calling the API (remove targets that are ancestors/dependents of others).","Prefer the high-level iterate_revisions()/upgrade/downgrade path rather than internal traversal helpers.","If hit via normal commands, check for duplicate or cross-dependent revision ids in your request."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# dedupe and de-overlap a requested target set\ntargets = list(dict.fromkeys(targets))  # unique, order preserved\n# if you traverse ancestors/dependents, drop targets already covered\n...","typeGuard":null,"tryCatchPattern":"from alembic.script.revision import RevisionError\ntry:\n    ...  # call passing the target set\nexcept RevisionError as e:\n    if 'overlaps' in str(e):\n        # remove overlapping targets and retry\n        ...","preventionTips":["Dedupe requested revision sets before traversal.","Prefer high-level iterate_revisions/upgrade/downgrade over internal helpers.","Avoid passing ancestor/dependent pairs together in one set."],"tags":["revision-map","overlapping-targets","internal","alembic"],"analyzedSha":"44fb3450330204b222ff05135e1fbbbdb28c44db","analyzedAt":"2026-08-04T19:57:10.248Z","schemaVersion":2}