-
Notifications
You must be signed in to change notification settings - Fork 67
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
[SYNPY-1453] Guard around modified time item in cache #1080
[SYNPY-1453] Guard around modified time item in cache #1080
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the quick bug fix, just a comment
@@ -161,8 +164,9 @@ def _get_cache_modified_time( | |||
""" | |||
if cache_map_entry is not None and "modified_time" in cache_map_entry: | |||
return cache_map_entry.get("modified_time", None) | |||
else: | |||
elif cache_map_entry is not None and isinstance(cache_map_entry, str): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand how this scenario occurs, but I'm confused as to how the cache map would get into that state. I know the old cache map looked something like this, but I thought we had tested downloading files between different cache map states.
{"/Users/tyu/.synapseCache/115/134016115/SYNAPSE_TABLE_QUERY_134016115.csv": "2024-03-07T06:29:19.000Z"}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I look around the old and new code and I couldn't really find an explanation. The only case I'm thinking is if the cache map entry looked like:
{"/Users/tyu/.synapseCache/115/134016115/SYNAPSE_TABLE_QUERY_134016115.csv": {}}
or
{"/Users/tyu/.synapseCache/115/134016115/SYNAPSE_TABLE_QUERY_134016115.csv": {"someOtherValue": 123}}
I compared the previous code from 3.1.0 to the code in the file now and I do not see anywhere we are intentionally setting the value to an empty dict, or a dict that does not contain the expected keys.
As for testing I had verified that going forward on client versions handled this gracefully.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔥 LGTM!
Problem:
modified_time
the code would return back the parent dict - causing further code to fail that was expecting a string to be returned.Solution:
_get_cache_modified_time
that verified that the data returned is going to be a string or the value formodified_time
Testing:
Added unit tests around the logic that verify the behavior if the cache map:
modified_time
key