Skip to content

Commit b29eff3

Browse files
authored
[QQC-2816] validate project names before creation (#1292)
2 parents dd51c41 + 2fea67e commit b29eff3

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

labelbox/client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,10 @@ def create_project(self, **kwargs) -> Project:
665665
"quality_mode must be set instead of auto_audit_percentage or auto_audit_number_of_labels."
666666
)
667667

668+
name = kwargs.get("name")
669+
if name is None or not name.strip():
670+
raise ValueError("project name must be a valid string.")
671+
668672
queue_mode = kwargs.get("queue_mode")
669673
if queue_mode is QueueMode.Dataset:
670674
raise ValueError(

tests/integration/test_legacy_project.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,13 @@ def test_project_auto_audit_parameters(client, rand_gen):
3434
"quality_mode must be set instead of auto_audit_percentage or auto_audit_number_of_labels."
3535
):
3636
client.create_project(name=rand_gen(str), auto_audit_number_of_labels=2)
37+
38+
39+
def test_project_name_parameter(client, rand_gen):
40+
with pytest.raises(ValueError,
41+
match="project name must be a valid string."):
42+
client.create_project()
43+
44+
with pytest.raises(ValueError,
45+
match="project name must be a valid string."):
46+
client.create_project(name=" ")

0 commit comments

Comments
 (0)