diff --git a/docs/schema/vault-v1/vault-v1.schema.json b/docs/schema/vault-v1/vault-v1.schema.json index a090acd..91d47ee 100644 --- a/docs/schema/vault-v1/vault-v1.schema.json +++ b/docs/schema/vault-v1/vault-v1.schema.json @@ -78,7 +78,7 @@ "required": ["url"], "properties": { "url": { "type": "string", "pattern": "^https://", "minLength": 9, "maxLength": 500, "description": "https-only evidence URL with content after the scheme (plain http and every other scheme are rejected)." }, - "label": { "type": "string", "maxLength": 120, "description": "Optional short display label, e.g. 'conference talk' or 'launch post'." } + "label": { "type": "string", "minLength": 1, "maxLength": 120, "description": "Optional short display label, e.g. 'conference talk' or 'launch post'." } }, "additionalProperties": false }, diff --git a/src/traitprint/schema.py b/src/traitprint/schema.py index 0db184e..bbbfb2e 100644 --- a/src/traitprint/schema.py +++ b/src/traitprint/schema.py @@ -195,7 +195,9 @@ class ArtifactLink(BaseModel): model_config = ConfigDict(extra="forbid") url: str = Field(min_length=len("https://") + 1, max_length=ARTIFACT_URL_MAX) - label: str | None = Field(default=None, max_length=ARTIFACT_LABEL_MAX) + label: str | None = Field( + default=None, min_length=1, max_length=ARTIFACT_LABEL_MAX + ) @field_validator("url") @classmethod diff --git a/tests/test_schema.py b/tests/test_schema.py index 2ea75c8..3e49369 100644 --- a/tests/test_schema.py +++ b/tests/test_schema.py @@ -332,6 +332,13 @@ def test_label_length_cap(self) -> None: with pytest.raises(ValidationError): ArtifactLink(url=url, label="x" * (ARTIFACT_LABEL_MAX + 1)) + def test_empty_label_rejected(self) -> None: + # Cloud parity: an empty label is rejected, not stored — a label + # is either meaningful text or absent (None). + with pytest.raises(ValidationError): + ArtifactLink(url="https://example.com", label="") + assert ArtifactLink(url="https://example.com", label=None).label is None + def test_max_links_per_entity(self) -> None: links = [ {"url": f"https://example.com/{i}"} for i in range(MAX_ARTIFACT_LINKS)