Skip to content

Commit fa2493b

Browse files
committed
chore(operator): redis
redis will always return data as string
1 parent 5f82b42 commit fa2493b

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

actions/devel/redis/__main__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ def build_response(data: CommandData):
3838
"statusCode": meta_data['status'],
3939
"body": meta_data['result']
4040
}
41-
if is_json(meta_data['result']):
42-
result['headers'] = { 'Content-Type': 'application/json' }
41+
print(f"{result}")
4342
return result
4443

4544
def parse_body(args):

actions/devel/redis/command/redis.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,20 @@ def execute(self, input:CommandData):
4646
try:
4747
r = redis.from_url(self._redis_url)
4848
result = r.execute_command(input.command())
49-
input.result(str(result.decode('utf-8')))
50-
input.status(200)
49+
50+
if result:
51+
input.status(200)
52+
# Ensure result is always a string
53+
if isinstance(result, bytes):
54+
result = result.decode("utf-8")
55+
else:
56+
result = str(result)
57+
58+
input.result(result)
59+
else:
60+
input.status(204)
61+
input.result(None)
62+
5163
except Exception as e:
5264
input.result(f"could not execute redis command {e}")
5365
input.status(400)

0 commit comments

Comments
 (0)