Skip to content

Commit f7cc76c

Browse files
claudeswaroopvarma1
authored andcommitted
Fix JSON conversion bug in template PUT endpoint
Fixed a bug where empty dictionaries for configurations, secrets, and schemas were incorrectly converted to NULL in the database instead of empty JSON objects. Changed the condition from 'if value' to 'if value is not None' for: - configurations_json - secrets_json - expected_payload_schema_json - expected_callback_response_schema_json This ensures that: - None → NULL in database (intended behavior) - {} → "{}" (empty JSON object, now works correctly) - {"key": "value"} → JSON string (continues to work) The bug was causing configuration updates to fail silently when the resulting dict was empty or falsy, as Python treats empty dicts as falsy. https://claude.ai/code/session_01N3rCYzU3puAwWKG1mszpHh
1 parent f03faca commit f7cc76c

1 file changed

Lines changed: 16 additions & 8 deletions

File tree

app/database/accessor/breeze_buddy/template.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,19 +105,23 @@ async def create_template(
105105
# Convert flow to JSON string
106106
flow_json = json.dumps(flow)
107107
expected_payload_schema_json = (
108-
json.dumps(expected_payload_schema) if expected_payload_schema else None
108+
json.dumps(expected_payload_schema)
109+
if expected_payload_schema is not None
110+
else None
109111
)
110112
expected_callback_response_schema_json = (
111113
json.dumps(expected_callback_response_schema)
112-
if expected_callback_response_schema
114+
if expected_callback_response_schema is not None
113115
else None
114116
)
115117

116118
# Convert configurations to JSON string
117-
configurations_json = json.dumps(configurations) if configurations else None
119+
configurations_json = (
120+
json.dumps(configurations) if configurations is not None else None
121+
)
118122

119123
# Convert secrets to JSON string
120-
secrets_json = json.dumps(secrets) if secrets else None
124+
secrets_json = json.dumps(secrets) if secrets is not None else None
121125

122126
query, values = create_template_query(
123127
template_id,
@@ -332,19 +336,23 @@ async def replace_template(
332336
# Convert flow to JSON string
333337
flow_json = json.dumps(flow)
334338
expected_payload_schema_json = (
335-
json.dumps(expected_payload_schema) if expected_payload_schema else None
339+
json.dumps(expected_payload_schema)
340+
if expected_payload_schema is not None
341+
else None
336342
)
337343
expected_callback_response_schema_json = (
338344
json.dumps(expected_callback_response_schema)
339-
if expected_callback_response_schema
345+
if expected_callback_response_schema is not None
340346
else None
341347
)
342348

343349
# Convert configurations to JSON string
344-
configurations_json = json.dumps(configurations) if configurations else None
350+
configurations_json = (
351+
json.dumps(configurations) if configurations is not None else None
352+
)
345353

346354
# Convert secrets to JSON string
347-
secrets_json = json.dumps(secrets) if secrets else None
355+
secrets_json = json.dumps(secrets) if secrets is not None else None
348356

349357
query, values = replace_template_query(
350358
template_id,

0 commit comments

Comments
 (0)