Delete item request through API causes omeka error

Hello,
I’m encountering an error that arises when a local python service on the server attempts to delete an item in omeka s. The line of code which sends the delete request is: r = requests.delete(uri, params=auth_params)

r.text then contains the generic omeka s error html page

Attempting to return r.json() raises an requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0) error.

The error recorded in the omeka s logs is

Doctrine\ORM\ORMInvalidArgumentException: Binding entities to query parameters only allowed for entities that have an identifier. in /var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/ORMInvalidArgumentException.php:221

Additional context that may be significant is that this occurs when a property of an item is changed which the service monitors. When it’s changed, the service deletes all children item of the parent item and then recreates them (It’s an ocr service). I validated that the item IDs in the URIs are valid as the items exist. The error does not stop the request from going through and the item being deleted.

The stack trace of the omeka s error is:

2022-10-22T15:48:17+00:00 ERR (3): Doctrine\ORM\ORMInvalidArgumentException: Binding entities to query parameters only allowed for entities that have an identifier. in /var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/ORMInvalidArgumentException.php:221
Stack trace:
#0 /var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php(438): Doctrine\ORM\ORMInvalidArgumentException::invalidIdentifierBindingEntity()
#1 /var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/Query.php(453): Doctrine\ORM\AbstractQuery->processParameterValue(NULL)
#2 /var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/Query.php(394): Doctrine\ORM\Query->resolveParameterValue(Object(Doctrine\ORM\Query\Parameter))
#3 /var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/Query.php(316): Doctrine\ORM\Query->processParameterMappings(Array)
#4 /var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php(1073): Doctrine\ORM\Query->_doExecute()
#5 /var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php(1027): Doctrine\ORM\AbstractQuery->executeIgnoreQueryCache(NULL, 1)
#6 /var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php(791): Doctrine\ORM\AbstractQuery->execute(NULL, 1)
#7 /var/www/html/application/src/Api/Adapter/AbstractResourceEntityAdapter.php(425): Doctrine\ORM\AbstractQuery->getResult()
#8 /var/www/html/application/src/Api/Representation/AbstractResourceEntityRepresentation.php(414): Omeka\Api\Adapter\AbstractResourceEntityAdapter->getSubjectValuesSimple(Object(Omeka\Entity\Media), NULL)
#9 /var/www/html/application/src/Api/Representation/AbstractResourceEntityRepresentation.php(112): Omeka\Api\Representation\AbstractResourceEntityRepresentation->subjectValuesForReverse()
#10 /var/www/html/application/src/Api/Representation/AbstractResourceRepresentation.php(75): Omeka\Api\Representation\AbstractResourceEntityRepresentation->getJsonLd()
#11 [internal function]: Omeka\Api\Representation\AbstractResourceRepresentation->jsonSerialize()
#12 /var/www/html/vendor/laminas/laminas-json/src/Json.php(360): json_encode(Object(Omeka\Api\Representation\MediaRepresentation), 15)
#13 /var/www/html/vendor/laminas/laminas-json/src/Json.php(325): Laminas\Json\Json::encodeViaPhpBuiltIn(Object(Omeka\Api\Representation\MediaRepresentation), false)
#14 /var/www/html/vendor/laminas/laminas-json/src/Json.php(98): Laminas\Json\Json::encodeValue(Object(Omeka\Api\Representation\MediaRepresentation), false, Array, false)
#15 /var/www/html/vendor/laminas/laminas-view/src/Renderer/JsonRenderer.php(150): Laminas\Json\Json::encode(Object(Omeka\Api\Representation\MediaRepresentation))
#16 /var/www/html/application/src/View/Renderer/ApiJsonRenderer.php(54): Laminas\View\Renderer\JsonRenderer->render(Object(Omeka\Api\Representation\MediaRepresentation))
#17 /var/www/html/vendor/laminas/laminas-view/src/View.php(206): Omeka\View\Renderer\ApiJsonRenderer->render(Object(Omeka\View\Model\ApiJsonModel))
#18 /var/www/html/vendor/laminas/laminas-mvc/src/View/Http/DefaultRenderingStrategy.php(104): Laminas\View\View->render(Object(Omeka\View\Model\ApiJsonModel))
#19 /var/www/html/vendor/laminas/laminas-eventmanager/src/EventManager.php(321): Laminas\Mvc\View\Http\DefaultRenderingStrategy->render(Object(Laminas\Mvc\MvcEvent))
#20 /var/www/html/vendor/laminas/laminas-eventmanager/src/EventManager.php(170): Laminas\EventManager\EventManager->triggerListeners(Object(Laminas\Mvc\MvcEvent))
#21 /var/www/html/vendor/laminas/laminas-mvc/src/Application.php(366): Laminas\EventManager\EventManager->triggerEvent(Object(Laminas\Mvc\MvcEvent))
#22 /var/www/html/vendor/laminas/laminas-mvc/src/Application.php(347): Laminas\Mvc\Application->completeRequest(Object(Laminas\Mvc\MvcEvent))
#23 /var/www/html/index.php(21): Laminas\Mvc\Application->run()
#24 {main}

An interesting error… it looks like the problem is just occurring when we try to return the JSON for the request response indicating that the record was deleted.

Can you share which version of Omeka S you’re using?

Yes, not assigning the response object to r avoids the omeka error, and not trying to return the JSON from the delete request response avoids the python error. I’m using Omeka S version 3.2.3. For now I’m avoiding the issue, but I wasn’t sure if it was expected behavior.

This topic was automatically closed 360 days after the last reply. New replies are no longer allowed.