diff --git a/gns3server/api/routes/controller/links.py b/gns3server/api/routes/controller/links.py index 5a51905e0..9e33b7ba3 100644 --- a/gns3server/api/routes/controller/links.py +++ b/gns3server/api/routes/controller/links.py @@ -458,6 +458,8 @@ async def create_marker( # uuid suffix avoids the collision that `marker-{link.id[:8]}` alone would # cause on the second anonymous marker on the same link (start_marker # rejects duplicate names). + if marker_data.name and marker_data.name.lower().startswith("global"): + raise ControllerError('Names starting with "global" are reserved for inherited markers') name = marker_data.name or f"marker-{link.id[:8]}-{uuid4().hex[:4]}" await link.start_marker( name=name, diff --git a/gns3server/api/routes/controller/projects.py b/gns3server/api/routes/controller/projects.py index 103c7d310..5e6f1c6de 100644 --- a/gns3server/api/routes/controller/projects.py +++ b/gns3server/api/routes/controller/projects.py @@ -260,6 +260,8 @@ async def create_marker_definition( Required privilege: Project.Modify """ + if def_data.name and def_data.name.lower().startswith("global"): + raise ControllerError('Names starting with "global" are reserved for inherited markers') name = def_data.name or f"def-{project.id[:8]}" await project.create_marker_definition( name=name, diff --git a/gns3server/schemas/controller/links.py b/gns3server/schemas/controller/links.py index 82bfc48b9..23a0cd18a 100644 --- a/gns3server/schemas/controller/links.py +++ b/gns3server/schemas/controller/links.py @@ -14,7 +14,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -from pydantic import BaseModel, Field, field_validator +from pydantic import BaseModel, Field from typing import List, Optional, Tuple from enum import Enum from uuid import UUID, uuid4 @@ -176,13 +176,6 @@ class MarkerCreate(BaseModel): description="Whether the marker is active. Defaults to true on creation.", ) - @field_validator("name") - @classmethod - def _check_name_not_reserved(cls, v): - if v is not None and v.lower().startswith("global"): - raise ValueError('Names starting with "global" are reserved') - return v - class MarkerDefinitionCreate(BaseModel): """ @@ -215,11 +208,4 @@ class MarkerDefinitionCreate(BaseModel): ), ) - @field_validator("name") - @classmethod - def _check_name_not_reserved(cls, v): - if v is not None and v.lower().startswith("global"): - raise ValueError('Names starting with "global" are reserved') - return v -