Explicitly check existing_indexes for None
This makes it clearer that a non-existent indexes node is not an
exceptional circumstance.
@@ -23,11 +23,11 @@ def merge_indexes(zk_client, project_id, new_indexes):
zk_client.ensure_path(indexes_node)
existing_indexes, znode_stat = zk_client.get(indexes_node)
node_version = znode_stat.version
- try:
+ if existing_indexes is None:
+ existing_indexes = []
+ else:
existing_indexes = [DatastoreIndex.from_dict(project_id, index)
for index in json.loads(existing_indexes)]
- except (TypeError, ValueError):
- existing_indexes = []
# Disregard index entries that already exist.
existing_index_defs = {index.encoded_def for index in existing_indexes}
