diff --git a/python/ray/serve/schema.py b/python/ray/serve/schema.py index 5435e0ed9bde..79b54787acee 100644 --- a/python/ray/serve/schema.py +++ b/python/ray/serve/schema.py @@ -947,10 +947,12 @@ class DeploymentDetails(BaseModel, extra=Extra.forbid, frozen=True): def deployment_route_prefix_not_set(cls, v: DeploymentSchema): # Route prefix should not be set at the deployment level. Deployment-level route # prefix is outdated, there should be one route prefix per application - if "route_prefix" in v.dict(exclude_unset=True): + if ( + "route_prefix" in v.__fields_set__ + ): # in Pydantic v2, this becomes `in v.model_fields_set` raise ValueError( "Unexpectedly found a deployment-level route_prefix in the " - f'deployment_config for deployment "{cls.name}". The route_prefix in ' + f'deployment_config for deployment "{v.name}". The route_prefix in ' "deployment_config within DeploymentDetails should not be set; please " "set it at the application level." )