silx-kit / h5web

React components for data visualization and exploration
https://h5web.panosc.eu/
MIT License
189 stars 19 forks source link

[NeXus] Error message when default is not found changes with the backend #618

Closed loichuder closed 3 years ago

loichuder commented 3 years ago

When the default attribute is not found (see group default_not_found), we get different error messages depending on the backend:

Perhaps we could have a more appropriate and unified error message for this particular case.

For the record, the other error messages (default_not_string, no_signal and signal_not_found) are consistent and clear.

axelboc commented 3 years ago

For Jupyter, see https://github.com/jupyterlab/jupyterlab-hdf5/issues/96.


With HSDS, when we look for an entity at a given path, we first fetch the root group, find the entity corresponding to the next segment in the path through the root group's children, and, if it's a group, fetch that group's children and keep going. We hit the error "Expected some value" (i.e. assertDefined), because at some point, the next segment in the path cannot be found amongst the children of a group.

We never fetch entities directly by their paths like in Jupyter, which explains why we don't get an error response.


One approach to solve this issue consistently would be to make sure every provider throws a specific error when an entity isn't found. The downside of this approach, is that providers don't know why we request entities (in this case because we're following a default attribute).

A second approach, which is what I'm going to try, would be for the getEntity method of every provider to return undefined instead of throwing an error when an entity is not found. This would allow us to have assertDefined calls with custom error messages after every call to entitiesStore.get(...), as it already is the case in getDefaultEntity.

We'd basically be bringing the behaviour of HSDS and Jupyter in line with the behaviour of the Mock provider.

axelboc commented 3 years ago

Not a fan of the second approach after all. Will try a catch-and-rethrow solution instead, to work around the limitation of the first approach.

axelboc commented 3 years ago

This issue concerns also the error message displayed when navigating to an entity that doesn't exist, notably when following a NeXus attribute like axis or signal in the metadata viewer.

The fix requires back-end providers to respond with a 404 to the request made from the getEntity API method. This is currently the case with HSDS, but not with H5Grove and jupyerlab-hdf5:

axelboc commented 3 years ago

Now fixed in all providers! :tada: :trophy: