Skip to content

Commit 888e10f

Browse files
author
Andrei Neagu
committed
fixed validator
1 parent d61ba00 commit 888e10f

File tree

1 file changed

+4
-4
lines changed
  • packages/models-library/src/models_library/api_schemas_long_running_tasks

1 file changed

+4
-4
lines changed

packages/models-library/src/models_library/api_schemas_long_running_tasks/tasks.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ class TaskBase(BaseModel):
2828

2929
@field_validator("task_name", mode="before")
3030
@classmethod
31-
def populate_task_name(cls, task_name: str, info):
31+
def populate_task_name_if_not_provided(cls, task_name: str, info):
3232
# attempt to extract the task name from the task_id
3333
# if this is coming form a long_running_task
34-
task_id = info.data.get("task_id")
35-
if task_id:
34+
task_id = info.data["task_id"]
35+
if task_id and task_name == "":
3636
parts = task_id.split(".")
37-
if len(parts) >= 2:
37+
if len(parts) > 1:
3838
task_name = urllib.parse.unquote(parts[1])
3939

4040
return task_name

0 commit comments

Comments
 (0)