ValueError: Cannot store Thing #223

Closed
opened 2026-06-24 07:01:56 +00:00 by mih · 3 comments
Owner

Using v6.1. with the setup in #222 and https://concepts.datalad.org/s/things/v2.yaml as a test schema. I see the following crash

❯ curl -X 'POST' \
  'http://localhost:8000/collection1/record/Thing?format=json' \
  -H 'accept: application/json' \
  -H 'X-DumpThings-Token: mytoken' \
  -H 'Content-Type: application/json' \
  -d '{"pid": "ex:thing1"}
'
Internal Server Error%                                                                                                    

with a server-side traceback of

INFO:     Started server process [3144789]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
INFO:     127.0.0.1:56996 - "POST /collections HTTP/1.1" 201 Created
INFO:     127.0.0.1:51314 - "POST /tokens HTTP/1.1" 201 Created
INFO:     127.0.0.1:60552 - "POST /collection1/record/Thing?format=json HTTP/1.1" 500 Internal Server Error
ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/home/mih/.local/share/uv/tools/dump-things-service/lib/python3.12/site-packages/uvicorn/protocols/http/httptools_impl.py", line 421, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mih/.local/share/uv/tools/dump-things-service/lib/python3.12/site-packages/uvicorn/middleware/proxy_headers.py", line 62, in __call__
    return await self.app(scope, receive, send)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mih/.local/share/uv/tools/dump-things-service/lib/python3.12/site-packages/fastapi/applications.py", line 1163, in __call__
    await super().__call__(scope, receive, send)
  File "/home/mih/.local/share/uv/tools/dump-things-service/lib/python3.12/site-packages/starlette/applications.py", line 90, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/home/mih/.local/share/uv/tools/dump-things-service/lib/python3.12/site-packages/starlette/middleware/errors.py", line 186, in __call__
    raise exc
  File "/home/mih/.local/share/uv/tools/dump-things-service/lib/python3.12/site-packages/starlette/middleware/errors.py", line 164, in __call__
    await self.app(scope, receive, _send)
  File "/home/mih/.local/share/uv/tools/dump-things-service/lib/python3.12/site-packages/starlette/middleware/cors.py", line 88, in __call__
    await self.app(scope, receive, send)
  File "/home/mih/.local/share/uv/tools/dump-things-service/lib/python3.12/site-packages/starlette/middleware/exceptions.py", line 63, in __call__
    await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
  File "/home/mih/.local/share/uv/tools/dump-things-service/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    raise exc
  File "/home/mih/.local/share/uv/tools/dump-things-service/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
    await app(scope, receive, sender)
  File "/home/mih/.local/share/uv/tools/dump-things-service/lib/python3.12/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
    await self.app(scope, receive, send)
  File "/home/mih/.local/share/uv/tools/dump-things-service/lib/python3.12/site-packages/starlette/routing.py", line 660, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/home/mih/.local/share/uv/tools/dump-things-service/lib/python3.12/site-packages/fastapi/routing.py", line 2531, in app
    await route.handle(scope, receive, send)
  File "/home/mih/.local/share/uv/tools/dump-things-service/lib/python3.12/site-packages/fastapi/routing.py", line 1241, in handle
    await super().handle(scope, receive, send)
  File "/home/mih/.local/share/uv/tools/dump-things-service/lib/python3.12/site-packages/starlette/routing.py", line 276, in handle
    await self.app(scope, receive, send)
  File "/home/mih/.local/share/uv/tools/dump-things-service/lib/python3.12/site-packages/fastapi/routing.py", line 150, in app
    await wrap_app_handling_exceptions(app, request)(scope, receive, send)
  File "/home/mih/.local/share/uv/tools/dump-things-service/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    raise exc
  File "/home/mih/.local/share/uv/tools/dump-things-service/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
    await app(scope, receive, sender)
  File "/home/mih/.local/share/uv/tools/dump-things-service/lib/python3.12/site-packages/fastapi/routing.py", line 136, in app
    response = await f(request)
               ^^^^^^^^^^^^^^^^
  File "/home/mih/.local/share/uv/tools/dump-things-service/lib/python3.12/site-packages/fastapi/routing.py", line 690, in app
    raw_response = await run_endpoint_function(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mih/.local/share/uv/tools/dump-things-service/lib/python3.12/site-packages/fastapi/routing.py", line 346, in run_endpoint_function
    return await run_in_threadpool(dependant.call, **values)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mih/.local/share/uv/tools/dump-things-service/lib/python3.12/site-packages/starlette/concurrency.py", line 34, in run_in_threadpool
    return await anyio.to_thread.run_sync(func)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mih/.local/share/uv/tools/dump-things-service/lib/python3.12/site-packages/anyio/to_thread.py", line 63, in run_sync
    return await get_async_backend().run_sync_in_worker_thread(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mih/.local/share/uv/tools/dump-things-service/lib/python3.12/site-packages/anyio/_backends/_asyncio.py", line 2592, in run_sync_in_worker_thread
    return await future
           ^^^^^^^^^^^^
  File "/home/mih/.local/share/uv/tools/dump-things-service/lib/python3.12/site-packages/anyio/_backends/_asyncio.py", line 1029, in run
    result = context.run(func, *args)
             ^^^^^^^^^^^^^^^^^^^^^^^^
  File "<string>", line 8, in _endpoint_collection1_store_Thing
  File "/home/mih/.local/share/uv/tools/dump-things-service/lib/python3.12/site-packages/dump_things_service/collection.py", line 607, in store_record
    stored_records = store.store_object(obj=record, submitter=user_id)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mih/.local/share/uv/tools/dump-things-service/lib/python3.12/site-packages/dump_things_service/store/model_store.py", line 52, in store_object
    raise ValueError(msg)
ValueError: Cannot store `Thing` instance: about=None annotations=None broad_mappings=None close_mappings=None description=None display_label=None display_note=None editorial_notes=None exact_mappings=None identifiers=None kind=None attributes=None characterized_by=None narrow_mappings=None related_mappings=None schema_type='dlthings:Thing' pid='ex:thing1' relations=None.
Using v6.1. with the setup in #222 and https://concepts.datalad.org/s/things/v2.yaml as a test schema. I see the following crash ``` ❯ curl -X 'POST' \ 'http://localhost:8000/collection1/record/Thing?format=json' \ -H 'accept: application/json' \ -H 'X-DumpThings-Token: mytoken' \ -H 'Content-Type: application/json' \ -d '{"pid": "ex:thing1"} ' Internal Server Error% ``` with a server-side traceback of ``` INFO: Started server process [3144789] INFO: Waiting for application startup. INFO: Application startup complete. INFO: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit) INFO: 127.0.0.1:56996 - "POST /collections HTTP/1.1" 201 Created INFO: 127.0.0.1:51314 - "POST /tokens HTTP/1.1" 201 Created INFO: 127.0.0.1:60552 - "POST /collection1/record/Thing?format=json HTTP/1.1" 500 Internal Server Error ERROR: Exception in ASGI application Traceback (most recent call last): File "/home/mih/.local/share/uv/tools/dump-things-service/lib/python3.12/site-packages/uvicorn/protocols/http/httptools_impl.py", line 421, in run_asgi result = await app( # type: ignore[func-returns-value] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/mih/.local/share/uv/tools/dump-things-service/lib/python3.12/site-packages/uvicorn/middleware/proxy_headers.py", line 62, in __call__ return await self.app(scope, receive, send) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/mih/.local/share/uv/tools/dump-things-service/lib/python3.12/site-packages/fastapi/applications.py", line 1163, in __call__ await super().__call__(scope, receive, send) File "/home/mih/.local/share/uv/tools/dump-things-service/lib/python3.12/site-packages/starlette/applications.py", line 90, in __call__ await self.middleware_stack(scope, receive, send) File "/home/mih/.local/share/uv/tools/dump-things-service/lib/python3.12/site-packages/starlette/middleware/errors.py", line 186, in __call__ raise exc File "/home/mih/.local/share/uv/tools/dump-things-service/lib/python3.12/site-packages/starlette/middleware/errors.py", line 164, in __call__ await self.app(scope, receive, _send) File "/home/mih/.local/share/uv/tools/dump-things-service/lib/python3.12/site-packages/starlette/middleware/cors.py", line 88, in __call__ await self.app(scope, receive, send) File "/home/mih/.local/share/uv/tools/dump-things-service/lib/python3.12/site-packages/starlette/middleware/exceptions.py", line 63, in __call__ await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) File "/home/mih/.local/share/uv/tools/dump-things-service/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app raise exc File "/home/mih/.local/share/uv/tools/dump-things-service/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app await app(scope, receive, sender) File "/home/mih/.local/share/uv/tools/dump-things-service/lib/python3.12/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__ await self.app(scope, receive, send) File "/home/mih/.local/share/uv/tools/dump-things-service/lib/python3.12/site-packages/starlette/routing.py", line 660, in __call__ await self.middleware_stack(scope, receive, send) File "/home/mih/.local/share/uv/tools/dump-things-service/lib/python3.12/site-packages/fastapi/routing.py", line 2531, in app await route.handle(scope, receive, send) File "/home/mih/.local/share/uv/tools/dump-things-service/lib/python3.12/site-packages/fastapi/routing.py", line 1241, in handle await super().handle(scope, receive, send) File "/home/mih/.local/share/uv/tools/dump-things-service/lib/python3.12/site-packages/starlette/routing.py", line 276, in handle await self.app(scope, receive, send) File "/home/mih/.local/share/uv/tools/dump-things-service/lib/python3.12/site-packages/fastapi/routing.py", line 150, in app await wrap_app_handling_exceptions(app, request)(scope, receive, send) File "/home/mih/.local/share/uv/tools/dump-things-service/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app raise exc File "/home/mih/.local/share/uv/tools/dump-things-service/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app await app(scope, receive, sender) File "/home/mih/.local/share/uv/tools/dump-things-service/lib/python3.12/site-packages/fastapi/routing.py", line 136, in app response = await f(request) ^^^^^^^^^^^^^^^^ File "/home/mih/.local/share/uv/tools/dump-things-service/lib/python3.12/site-packages/fastapi/routing.py", line 690, in app raw_response = await run_endpoint_function( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/mih/.local/share/uv/tools/dump-things-service/lib/python3.12/site-packages/fastapi/routing.py", line 346, in run_endpoint_function return await run_in_threadpool(dependant.call, **values) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/mih/.local/share/uv/tools/dump-things-service/lib/python3.12/site-packages/starlette/concurrency.py", line 34, in run_in_threadpool return await anyio.to_thread.run_sync(func) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/mih/.local/share/uv/tools/dump-things-service/lib/python3.12/site-packages/anyio/to_thread.py", line 63, in run_sync return await get_async_backend().run_sync_in_worker_thread( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/mih/.local/share/uv/tools/dump-things-service/lib/python3.12/site-packages/anyio/_backends/_asyncio.py", line 2592, in run_sync_in_worker_thread return await future ^^^^^^^^^^^^ File "/home/mih/.local/share/uv/tools/dump-things-service/lib/python3.12/site-packages/anyio/_backends/_asyncio.py", line 1029, in run result = context.run(func, *args) ^^^^^^^^^^^^^^^^^^^^^^^^ File "<string>", line 8, in _endpoint_collection1_store_Thing File "/home/mih/.local/share/uv/tools/dump-things-service/lib/python3.12/site-packages/dump_things_service/collection.py", line 607, in store_record stored_records = store.store_object(obj=record, submitter=user_id) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/mih/.local/share/uv/tools/dump-things-service/lib/python3.12/site-packages/dump_things_service/store/model_store.py", line 52, in store_object raise ValueError(msg) ValueError: Cannot store `Thing` instance: about=None annotations=None broad_mappings=None close_mappings=None description=None display_label=None display_note=None editorial_notes=None exact_mappings=None identifiers=None kind=None attributes=None characterized_by=None narrow_mappings=None related_mappings=None schema_type='dlthings:Thing' pid='ex:thing1' relations=None. ```
Owner

The server does not support POST-ing instances of Thing. The endpoints should not exist. This is fixed in commit 49cf0d22b2

The server does not support POST-ing instances of `Thing`. The endpoints should not exist. This is fixed in commit 49cf0d22b2ceb3a32bd7158af94e48326695177a
Author
Owner

I can confirm that with the following modification to the schema, and posting to the then added endpoint, the submission works fine.

diff --git a/testschema.yaml b/testschema.yaml
index dc7accf..4dfc056 100644
--- a/testschema.yaml
+++ b/testschema.yaml
@@ -656,3 +656,6 @@ classes:
     is_a: Thing
     title: Annotation tag
     description: A tag identifying an annotation.
+
+  RealThing:
+    is_a: Thing
I can confirm that with the following modification to the schema, and posting to the then added endpoint, the submission works fine. ```diff diff --git a/testschema.yaml b/testschema.yaml index dc7accf..4dfc056 100644 --- a/testschema.yaml +++ b/testschema.yaml @@ -656,3 +656,6 @@ classes: is_a: Thing title: Annotation tag description: A tag identifying an annotation. + + RealThing: + is_a: Thing ```
Author
Owner

As of v6.2 this is now working.

As of v6.2 this is now working.
mih closed this issue 2026-06-25 06:04:48 +00:00
Sign in to join this conversation.
No milestone
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
orinoco/dump-things-service#223
No description provided.