Skip to content

Fix Google Sheets rows that lose cells or stop at 100 rows, and the Decision node's default state - #1090

Merged
ckakgun merged 5 commits into
heymrun:mainfrom
ersinkoc:fix/batch-ab
Nov 22, 2026
Merged

ckakgun merged 5 commits into
heymrun:mainfrom
ersinkoc:fix/batch-ab

Conversation

@ersinkoc

@ersinkoc ersinkoc commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Three fixes: two Google Sheets reads and the Decision node's default state. The last two commits answer the review (see "Review changes"). I ran step 3 against main (deb260a) and against this branch, on two local instances. I have no Google account connected here, so the two Sheets fixes are shown with tests against a mocked Sheets API.

The steps share this setup:

export HEYM=http://localhost:10105          # your Heym backend
export TOKEN=...                             # a bearer token (POST /api/auth/login)
H=(-H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json")
id_of() { python3 -c 'import json,sys;print(json.load(sys.stdin)["id"])'; }
new_workflow() {  # new_workflow <name> <graph.json>  -> prints the id
  local id; id=$(curl -s "${H[@]}" -X POST "$HEYM/api/workflows" -d "{\"name\":\"$1\"}" | id_of)
  curl -s -o /dev/null "${H[@]}" -X PUT "$HEYM/api/workflows/$id" -d @"$2"; echo "$id"
}

1. Google Sheets rows lose cells under repeated and blank titles, and past the header

readRange (with "Use first row as header") and the Google Sheets Trigger build each row as {title: cell}. A repeated title keeps only the last such column, every column without a title shares the key "", and a column past the end of the header row is dropped (the Sheets API leaves trailing empty cells out of the header row). For a header Name, "", Notes, Notes and the row Ada, vip, called, emailed, late, main returns {"Name": "Ada", "": "vip", "Notes": "emailed", "rowIndex": 2}: called and late are gone.

Rows now keep every key main returns, with the same value and order, and after rowIndex add the cells no title holds, keyed by the column letter (or C_2 when that key is taken). Every blank-titled column also gets its letter key (keeping ""), since the columns endpoint names it by its letter and Heym Work saves that name. The same row reads {"Name": "Ada", "": "vip", "Notes": "emailed", "rowIndex": 2, "B": "vip", "C": "called", "E": "late"}. The columns endpoint and the trigger's changed_columns are unchanged. The node pages and the DSL describe the rule.

Tests: test_read_range_adds_the_cells_a_title_cannot_hold_after_the_old_keys, test_every_key_main_returns_keeps_its_value_and_order and test_a_dropped_cell_whose_letter_is_taken_gets_a_suffix in tests/test_google_sheets_service.py, and RepeatedAndBlankHeaderTests in tests/test_google_sheets_trigger_source.py.

2. Google Sheets Max rows 0 as a number, empty or unset reads 100 rows

The docs, the DSL prompt and the editor ("Max rows (0 = all)", which shows 0 when the field is unset) say 0 reads every row. The node read str(node_data.get("gsMaxRows", "100") or "100"), so a number 0 (as the AI builder writes it), a cleared field and a missing field became 100, and the rows after the 100th were cut off without a word. Only the text "0" read them all. Those now read every row; any other number still caps the range.

Tests: test_zero_blank_or_unset_max_rows_reads_every_row and test_a_max_rows_number_still_caps_the_range in tests/test_google_sheets_node_blank_fields.py, which check the A1 range sent to the Sheets API (Sheet1!A1:Z against Sheet1!A1:Z101 on main).

3. A Decision node without state sends null

The docs and the DSL prompt give state the default $input.text, and the canvas sets it on new nodes, but the handler sent the field as it was: a node built without it, as the AI builder may write one, sent "state": null, and the model had nothing to read. An unset state now reads $input.text; an explicit value, including an empty one, is sent as written.

With a stand-in for the Decision Model API that answers with the state it received ($DECISION_URL, a local listener on 127.0.0.1, so the backend needs HEYM_HTTP_ALLOW_PRIVATE_URLS=true):

CRED=$(curl -s "${H[@]}" -X POST "$HEYM/api/credentials" -d "{\"name\":\"Decision\",\"type\":\"decision\",\"config\":{\"base_url\":\"$DECISION_URL\",\"api_key\":\"k\"}}" | id_of)
cat > triage.json <<EOF
{"nodes":[
 {"id":"in_1","type":"textInput","position":{"x":0,"y":0},"data":{"label":"userInput","inputFields":[{"key":"text"}]}},
 {"id":"d1","type":"decision","position":{"x":300,"y":0},"data":{"label":"triage","credentialId":"$CRED","model":"jev-latest","questions":[{"id":"q","type":"noul","instructions":"Urgent?"}]}}],
 "edges":[{"id":"e1","source":"in_1","target":"d1"}]}
EOF
W=$(new_workflow "Triage" triage.json)
curl -s "${H[@]}" -X POST "$HEYM/api/workflows/$W/execute" -d '{"text":"Payouts are failing"}' | python3 -c 'import json,sys;print(json.load(sys.stdin)["triage"]["received_state"])'
  • main: None
  • This branch: Payouts are failing

Test: test_an_unset_state_reads_the_input_text in tests/test_decision_node.py.

Review changes

  1. The Switch commit is dropped: a Switch compares the value as written.
  2. The global variable commit is dropped.
  3. Sheets rows are additive: every key main returns keeps its value and order, and only the cells main drops are added after rowIndex, keyed by the column letter (_2 when taken). The columns endpoint and changed_columns are as on main, and a test checks the main keys for several headers.
  4. Both node pages and the DSL's readRange and trigger row lines describe that rule.

Second round

  1. The trigger computes the widest row once per snapshot (SheetSnapshot.width) instead of for every row: a 10,000-row tab with every row changed takes 0.13 s per diff here, against 3.17 s on the previous commit and 0.12 s on main (best of three, same machine). test_the_snapshot_width_is_computed_once_and_used_for_every_row.
  2. Every blank-titled column also gets its letter key, keeping "" (test_a_single_blank_title_is_also_keyed_by_its_letter); the node pages and the DSL say so.

Checks

./run_tests.sh against PostgreSQL: 9848 tests, 9848 passed.

ruff check, ruff format --check, git diff --check and scripts/check-file-line-limits.sh pass.

@ckakgun ckakgun added the next label Nov 22, 2026
@ckakgun

ckakgun commented Nov 22, 2026

Copy link
Copy Markdown
Collaborator

Thanks for this batch! Max rows and the Decision default state look good. Before we can merge, a few changes:

  1. Please drop the Switch commit. A Switch compares the value as written, so 4.0 going to default for a case 4 is the behavior we want.
  2. Please drop the global variable commit. A type-only PATCH is only reachable by calling the API directly; the editor, Heym Work and the Variable node always send the value. Please only include fixes for things a user can hit from the UI, Heym Work or a node.
  3. Sheets columns must be additive. Today a repeated title's key holds the last column's cell and a blank title is keyed "", and workflows read those. Heym Work also stores the columns endpoint's names in saved flows and matches them by name, so a renamed column loses its saved value. Please keep every key main returns with the same value and order, and only add the cells that are dropped today (a blank-titled column, an earlier column with a repeated title, a column past the header end) after them, keyed by the column letter (with _2 if that key is taken). Keep the columns endpoint and changed_columns as they are on main, and add a test that every key main returns keeps its value.
  4. Docs and DSL: describe that rule on the two node pages and in the readRange and trigger row key lines of workflow_dsl_prompt.py.

Thanks again 🙏

readRange and the Google Sheets Trigger built each row as
{header title: cell}. Two columns titled "Notes" kept only the last,
every column without a title shared the key "", and a column past the
header row's end (Sheets drops trailing empty header cells) was dropped.
The column picker already named a blank-titled column by its letter.
One helper now keys the columns for all three: the title, the column
letter when there is none, and _2, _3 for a repeated title, never
taking another column's real title.
The docs, the DSL prompt and the editor ("Max rows (0 = all)", shown as
0 when unset) say 0 reads every row. The node turned a number 0, a
cleared field and a missing field into 100, so rows after the 100th
were cut off silently; only the text "0" read them all. Those now read
every row too.
The docs and the DSL prompt give state the default $input.text, and the
canvas sets it on new nodes, but the handler sent the field as it was:
a node built without it, as the AI builder may write one, sent
"state": null and the model had nothing to read. An unset state now
reads $input.text; an explicit value is sent as written.
Renaming columns changed keys workflows read and names Heym Work stores
from the columns endpoint. Rows now keep main's keys with the same value
and order (each title holds its column's cell, a repeated title the last
such column, blank titles ""), and after rowIndex add the cells no title
holds (an earlier column with a repeated or blank title, a column past
the header row's end) keyed by the column letter, or B_2 when taken.
The columns endpoint and the trigger's changed_columns are as on main.
The node pages and the DSL describe the rule; a test checks that every
key main returns keeps its value and order.
@ersinkoc ersinkoc changed the title Fix Switch on whole floats, Google Sheets rows that lose columns or stop at 100, global variable type changes, and the Decision node's default state Fix Google Sheets rows that lose cells or stop at 100 rows, and the Decision node's default state Nov 22, 2026
@ersinkoc

Copy link
Copy Markdown
Contributor Author

Thanks, and noted on the scope (UI, Heym Work or a node only). Done:

  1. Switch commit dropped.
  2. Global variable commit dropped.
  3. Sheets rows are additive now: every key main returns keeps its value and order (a repeated title still holds the last column, blank titles still ""), and only the cells main drops (an earlier repeated or blank-titled column, a column past the header end) are added after rowIndex, keyed by the column letter, with _2 when taken. The columns endpoint and changed_columns are back to main. test_every_key_main_returns_keeps_its_value_and_order checks the main keys for four headers.
  4. Both node pages and the DSL's readRange and trigger row lines describe the rule (with a test that they do).

The branch is rebased on main (deb260a); the Decision step gives the same result there, and the full suite passes (9846).

@ckakgun

ckakgun commented Nov 22, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the quick update! All four points are in, and every key main returns keeps its value. Two things before we merge:

  1. Trigger poll time: row_object recomputes the width over every row of the snapshot, and diff_sheet calls it for each row, so a poll grows with the square of the rows. A 10,000-row tab took 4.3 to 7.2 s per poll against about 0.5 s on main. Please compute the width once per snapshot and pass it in; with that it is back to about 0.5 s.
  2. A single blank-titled column: the columns endpoint names it by its letter, and Heym Work saves that name, but with one blank title the row only has "", so a Work "Keep as it is" step writes the literal $sheetEvent.row.B into the cell. Please give every blank-titled column its letter key too (keeping ""), and update the test, the two node pages and the DSL line.

Thanks again 🙏

row_object recomputed the widest row for every row of a trigger poll,
so a poll grew with the square of the rows (3.2 s for 10,000 rows
against 0.12 s on main). build_snapshot now computes the width once and
row_object reads it (0.13 s).

Every blank-titled column also gets its letter key, keeping "": the
columns endpoint names such a column by its letter and Heym Work saves
that name, but with one blank title the row only had "".
@ersinkoc

Copy link
Copy Markdown
Contributor Author

Thanks, both fixed in 48846d3:

  1. build_snapshot computes the widest row once and stores it on the snapshot (SheetSnapshot.width); row_object reads it. On this machine a 10,000-row tab with every row changed takes 0.13 s per diff, against 3.17 s on the previous commit and 0.12 s on main (best of three). A test checks that row_object uses the snapshot's width.
  2. Every blank-titled column also gets its letter key, keeping "", so a single blank title gives both "" and B. The test, both node pages and the DSL line are updated.

Full suite: 9848 passed.

@ckakgun

ckakgun commented Nov 22, 2026

Copy link
Copy Markdown
Collaborator

Thank you!

@ckakgun
ckakgun merged commit 43fde1b into heymrun:main Nov 22, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

2 participants