Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix jsonToArray on None array #284

Merged

Conversation

mattjala
Copy link
Contributor

@mattjala mattjala commented Nov 1, 2023

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.

@mattjala mattjala added the bug label Nov 1, 2023
@mattjala mattjala force-pushed the fix_json_to_array_empty_compound_read branch from aad10f6 to d983841 Compare November 1, 2023 22:04
@jreadey
Copy link
Member

jreadey commented Nov 3, 2023

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?

@mattjala mattjala force-pushed the fix_json_to_array_empty_compound_read branch 2 times, most recently from 49a8638 to 20c3c6f Compare November 3, 2023 17:57
"""


def _bytesArrayToList(data):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't used anywhere else, so I just removed it.

@mattjala mattjala force-pushed the fix_json_to_array_empty_compound_read branch from 20c3c6f to 5aaab9e Compare November 3, 2023 17:59
@mattjala mattjala force-pushed the fix_json_to_array_empty_compound_read branch from 5aaab9e to b0b7158 Compare November 6, 2023 20:39
@jreadey
Copy link
Member

jreadey commented Nov 9, 2023

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

@mattjala
Copy link
Contributor Author

mattjala commented Nov 9, 2023

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.

Copy link
Member

@jreadey jreadey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good!

@jreadey jreadey merged commit a6c2c26 into HDFGroup:master Nov 10, 2023
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants