Skip to content

Commit 932b273

Browse files
committed
Fixed json parsing in set cache
1 parent 77896dd commit 932b273

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

shuffle-tools/1.2.0/src/app.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1755,13 +1755,22 @@ def get_cache_value(self, key):
17551755
def set_cache_value(self, key, value):
17561756
org_id = self.full_execution["workflow"]["execution_org"]["id"]
17571757
url = "%s/api/v1/orgs/%s/set_cache" % (self.url, org_id)
1758+
1759+
if isinstance(value, dict) or isinstance(value, list) or isinstance(value, object):
1760+
try:
1761+
value = json.dumps(value)
1762+
except:
1763+
pass
1764+
elif not isinstance(value, str):
1765+
value = str(value)
1766+
17581767
data = {
17591768
"workflow_id": self.full_execution["workflow"]["id"],
17601769
"execution_id": self.current_execution_id,
17611770
"authorization": self.authorization,
17621771
"org_id": org_id,
17631772
"key": key,
1764-
"value": str(value),
1773+
"value": value,
17651774
}
17661775

17671776
response = requests.post(url, json=data)
@@ -1774,7 +1783,7 @@ def set_cache_value(self, key, value):
17741783
try:
17751784
allvalues["value"] = json.loads(value)
17761785
except json.decoder.JSONDecodeError as e:
1777-
self.logger.info("Failed inner value parsing: %s" % e)
1786+
self.logger.info("[WARNING] Failed inner value cache parsing: %s" % e)
17781787
allvalues["value"] = str(value)
17791788
else:
17801789
allvalues["value"] = str(value)

0 commit comments

Comments
 (0)