HDFGroup / hsds

Cloud-native, service based access to HDF data
https://www.hdfgroup.org/solutions/hdf-kita/
Apache License 2.0
126 stars 52 forks source link

Fix jsonToArray on None array #284

Closed mattjala closed 7 months ago

mattjala commented 8 months ago

This is the same issue that was partially fixed in #237, where None elements in a value array caused issues in the helper jsonToArray. This covers the case where the entire value array is None (e.g. an attribute that was created but not written to). It now returns an empty numpy array instead of throwing an exception.

This also makes HSDS log the error messages jsonToArray produces, and adds a try/except block when doing a bytes decode that can fail.

jreadey commented 8 months ago

Good - not sure what I was thinking with the "if None in data_json...". Let's keep the HTTP exceptions out of arrayUtil.py. Would prefer the calling function catch ValueError and then raise HTTP... exception as appropriate. Also, could you merge in the latest changes from master?

jreadey commented 7 months ago

Why do you have the extra parens? e.g.if (value is None): vs if value is None:

mattjala commented 7 months ago

Why do you have the extra parens? e.g.if (value is None): vs if value is None:

Force of habit from working in C. I'll clean those up.