Skip to content

Commit

Permalink
fix(client): Serialize properly playbooks with empty values (#4338)
Browse files Browse the repository at this point in the history
* Card ID: CCT-1102

Empty values in playbooks were not serialized correctly. This commit
resolves the issue by ensuring that empty values are not enclosed in
quotes in the serialized output.

Signed-off-by: pkoprda <[email protected]>
  • Loading branch information
pkoprda authored Jan 15, 2025
1 parent f8451aa commit a9f19da
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def _obj(cls, value):
logger.debug("Value type not recognized, it may misbehave: {value} ({typ})".format(
value=value, typ=type(value).__name__)
)
return "'" + str(value) + "'"
return str(value)

@classmethod
def _str(cls, value):
Expand Down
6 changes: 6 additions & 0 deletions insights/tests/client/apps/test_playbook_verifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,12 @@ def test_list(self):
expected = "['value1', 'value2']"
assert result == expected

def test_dict_empty_value(self):
source = {"key": None}
result = playbook_verifier.PlaybookSerializer.serialize(source)
expected = "ordereddict([('key', None)])"
assert result == expected

def test_dict_single_key(self):
source = {"key": "value"}
result = playbook_verifier.PlaybookSerializer.serialize(source)
Expand Down

0 comments on commit a9f19da

Please sign in to comment.