Skip to content

[Serve] serve.run can bind the incorrect Application if Deployments have the same name #53295

@paul-twelvelabs

Description

@paul-twelvelabs

What happened + What you expected to happen

Create Parent/Child Deployments, manually assign both the same name, in this case "common", and pass the Child as a __init__ arg to the Parent. Serve detects a name conflict and renames one of the deployments "common_1", but serve.run(...) incorrectly binds to the Child app even though it's called with the Parent app as an explicit argument. I'd expect the return value of has_child to be True, but it's False.

repro

from ray import serve
from ray.serve import handle

class Repro:
    def __init__(self, child: handle.DeploymentHandle | None = None) -> None:
        self._child = child

    async def has_child(self) -> bool:
        return self._child is not None

@serve.deployment(name="common")
class Parent(Repro):
    ...

@serve.deployment(name="common")
class Child(Repro):
    ...

app_dh = serve.run(Parent.bind(child=Child.bind()), blocking=False)

# call
print(f">> has child: {await app_dh.has_child.remote()}")

logs

WARNING 2025-05-24 08:54:16,712 serve 12526 -- There are multiple deployments with the same name 'common'. Renaming one to 'common_1'.
...
(ServeController pid=19136) INFO 2025-05-24 08:54:17,868 controller 19136 -- Deploying new version of Deployment(name='common', app='default') (initial target replicas: 1).
(ServeController pid=19136) INFO 2025-05-24 08:54:17,869 controller 19136 -- Deploying new version of Deployment(name='common_1', app='default') (initial target replicas: 1).
...
>> has child: False

Of note, you'll get the correct result if you remove name="common" arg from the serve.deployment decorator as the Deployments will have unique names.

Versions / Dependencies

ray==2.46.0
python==3.12

Reproduction script

please see above!

Issue Severity

Minor

Metadata

Metadata

Assignees

Labels

P1Issue that should be fixed within a few weeksbugSomething that is supposed to be working; but isn'tserveRay Serve Related Issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions