Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/schema/vault-v1/vault-v1.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
Expand Down
4 changes: 3 additions & 1 deletion src/traitprint/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions tests/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading