From b34350746fdbeb370420b20c1c8ca75921ae19ae Mon Sep 17 00:00:00 2001 From: Luccas Gomes Date: Thu, 15 Oct 2026 07:19:12 -0300 Subject: [PATCH] fix(create): send schema with resource_create CKAN may validate the schema when the resource is created: ckanext-neso rejects an upsert resource without schema.primaryKey. The schema was only added by the post-write resource_patch, so datastore_create with a new upsert resource always failed with 'CKAN denied resource_create'. --- datastore/services/write.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/datastore/services/write.py b/datastore/services/write.py index bde2ee2..e7f2ee8 100644 --- a/datastore/services/write.py +++ b/datastore/services/write.py @@ -149,9 +149,13 @@ async def create_datastore( # Tag the new resource as datastore-managed so CKAN (and our own # read-only guard on subsequent writes) knows the datastore owns # its data. Caller-supplied url_type is overridden on purpose. + # The schema goes in up front too: CKAN may validate it on create + # (e.g. an `upsert` resource must declare a primaryKey), so leaving + # it to the post-write sync would reject the resource. resource = await context.ckan.resource_create( resource={ **resource, + "schema": schema, "url_type": "datastore", "datastore_active": True, }