Skip to content

Commit b92c7c0

Browse files
RafaelPoclaude
andcommitted
Fix None values written as literal "None" in Google Sheets
records_to_values used str(record.get(h, "")) which only defaulted to "" for missing keys. When the key existed with value None (from pandas NaN), str(None) produced the string "None" in sheet cells instead of empty. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent cc8e97c commit b92c7c0

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

everyrow-mcp/src/everyrow_mcp/sheets_client.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,5 +301,10 @@ def records_to_values(records: list[dict[str, Any]]) -> list[list[str]]:
301301

302302
rows = [headers]
303303
for record in records:
304-
rows.append([str(record.get(h, "")) for h in headers])
304+
rows.append(
305+
[
306+
str(v) if v is not None else ""
307+
for v in (record.get(h, "") for h in headers)
308+
]
309+
)
305310
return rows

everyrow-mcp/tests/test_sheets_tools.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,13 @@ def test_missing_keys_become_empty(self):
194194
values = records_to_values(records)
195195
assert values[2] == ["3", ""]
196196

197+
def test_none_values_become_empty(self):
198+
"""None values (e.g. from pandas NaN) should become empty strings, not 'None'."""
199+
records = [{"name": "Alice", "age": None}, {"name": None, "age": "30"}]
200+
values = records_to_values(records)
201+
assert values[1] == ["Alice", ""]
202+
assert values[2] == ["", "30"]
203+
197204

198205
# ── Client tests (mocked httpx) ─────────────────────────────────────
199206

0 commit comments

Comments
 (0)