Task #9001 (closed)
Opened 7 years ago
Closed 7 years ago
BUG: omero.gateway getObject should raise an error while non of the args are set
| Reported by: | atarkowska | Owned by: | atarkowska |
|---|---|---|---|
| Priority: | major | Milestone: | OMERO-4.4 |
| Component: | OmeroPy | Version: | n.a. |
| Keywords: | n.a. | Cc: | web-team@… |
| Resources: | n.a. | Referenced By: | n.a. |
| References: | n.a. | Remaining Time: | 0.0d |
| Sprint: | 2012-06-19 (17) |
Description (last modified by atarkowska)
Traceback (most recent call last):
File "/Users/ola/Dev/omero/dist/lib/python/omeroweb/webadmin/tests/unittests.py", line 377, in test_createGroupsWithNonASCII
group = conn.getObject("ExperimenterGroup", gid)
File "/Users/ola/Dev/omero/dist/lib/python/omero/gateway/__init__.py", line 2498, in getObject
result = self.getQueryService().findByQuery(query, params, self.CONFIG['SERVICE_OPTS'])
File "/Users/ola/Dev/omero/dist/lib/python/omero/gateway/__init__.py", line 3267, in __call__
return self.handle_exception(e, *args, **kwargs)
File "/Users/ola/Dev/omero/dist/lib/python/omeroweb/webclient/webclient_gateway.py", line 1822, in handle_exception
e, *args, **kwargs)
File "/Users/ola/Dev/omero/dist/lib/python/omero/gateway/__init__.py", line 3264, in __call__
return self.f(*args, **kwargs)
File "/Users/ola/Dev/omero/dist/lib/python/omero_api_IQuery_ice.py", line 133, in findByQuery
return _M_omero.api.IQuery._op_findByQuery.invoke(self, ((query, params), _ctx))
ApiUsageException: exception ::omero::ApiUsageException
{
serverStackTrace = ome.conditions.ApiUsageException: Query named:
select distinct obj from ExperimenterGroup as obj left outer join fetch obj.groupExperimenterMap as map left outer join fetch map.child e
has returned more than one Object
findBy methods must return a single value.
Please try findAllBy methods for queries which return Lists.
The error is misleading
Change History (6)
comment:1 Changed 7 years ago by atarkowska
- Cc web-team@… added
- Component changed from General to OmeroPy
- Description modified (diff)
- Priority changed from minor to major
comment:2 Changed 7 years ago by atarkowska
- Status changed from new to accepted
comment:3 Changed 7 years ago by atarkowska
comment:4 Changed 7 years ago by wmoore
See #5168. We deliberately use findByQuery so that if I do getObject("Image") I don't load all Images to the client. The server has this checking functionality specifically for this use case. If you want to catch the server's exception at the BlitzGateway? and provide a nicer error message, that might be a nicer way to go, although I think that the server's error message is quite informative.
comment:5 Changed 7 years ago by jburel
- Sprint changed from 2012-06-05 (16) to 2012-06-19 (17)
Moved from sprint 2012-06-05 (16)
comment:6 Changed 7 years ago by atarkowska
- Remaining Time changed from 0.1 to 0
- Resolution set to invalid
- Status changed from accepted to closed
As there are various pros and cons this ticket is invalid
In order to make the error more clear we could use findAllByQuery and then check if there is more then 1 results.
if len(result) > 1: raise AttributeError("getObject methods has returned more than one Object but must return a single value. Please try getObjects methods for queries which return Lists.")method also doesn't contain return statement for no results.