Skip to content

Commit 595b0be

Browse files
authored
fix: reject items without a collection ID (#133)
1 parent c9915dd commit 595b0be

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

lib/ingestor-api/runtime/src/schemas.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def is_accessible(cls, href):
4343

4444
class AccessibleItem(Item):
4545
assets: Dict[str, AccessibleAsset]
46+
collection: str # override because default is str | None
4647

4748
@field_validator("collection")
4849
def exists(cls, collection):

lib/ingestor-api/runtime/tests/test_registration.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,19 @@ def test_validates_missing_collection(
9797
len(self.db.fetch_many(status="queued")["items"]) == 0
9898
), "data should not be stored in DB"
9999

100+
def test_validates_no_collection_id(self, asset_exists):
101+
item_sans_id = self.example_ingestion.item.model_copy()
102+
item_sans_id.collection = None
103+
104+
response = self.api_client.post(
105+
ingestion_endpoint,
106+
json=item_sans_id.model_dump(mode="json"),
107+
)
108+
assert response.status_code == 422, "should get validation error"
109+
assert (
110+
len(self.db.fetch_many(status="queued")["items"]) == 0
111+
), "data should not be stored in DB"
112+
100113
def test_validates_missing_assets(
101114
self, client_authenticated, collection_exists, asset_missing
102115
):

0 commit comments

Comments
 (0)