Skip to content

Fix mail trigger dates shifted by the server time zone, and node docs and DSL fields that do not exist - #1088

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

ckakgun merged 9 commits into
heymrun:mainfrom
ersinkoc:fix/batch-aa

Conversation

@ersinkoc

@ersinkoc ersinkoc commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Five fixes, one commit each. The first changes code: the mail triggers' date. The other four correct node pages and the AI builder's DSL prompt where they name fields or defaults the nodes do not have, with tests that check the pages and the prompt against the handlers.

I ran step 1 against main (e23686b) and against this branch, on two local instances. Steps 2 to 4 only change docs and the DSL prompt, so they print the same on both; they show that the documented form does not work and the corrected one does.

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. A mail's date is shifted by the server's time zone when the Date header says -0000

RFC 5322 (3.3) writes -0000 for a time in UTC whose sender's zone is unknown, and Python's own email.utils.formatdate() writes it by default. parsedate_to_datetime returns such a date without a zone, and email_payload then called .astimezone(timezone.utc), which reads a zone-less datetime as the server's local time. backend/Dockerfile sets TZ=Europe/Berlin and docker-compose defaults to it, so 10:00:00 -0000 came out as 09:00Z in winter and 08:00Z in summer. The IMAP, Gmail and Outlook triggers all build their payload with email_payload. A zone-less date is now taken as UTC.

With an IMAP server on 127.0.0.1 (I used GreenMail: docker run -p 3025:3025 -p 3143:3143 -e GREENMAIL_OPTS='-Dgreenmail.setup.test.all -Dgreenmail.hostname=0.0.0.0 -Dgreenmail.auth.disabled' greenmail/standalone:2.1.0) and a backend whose TZ is not UTC:

MAILBOX=ops@example.com
CRED=$(curl -s "${H[@]}" -X POST "$HEYM/api/credentials" -d "{\"name\":\"Ops inbox\",\"type\":\"imap\",\"config\":{\"imap_host\":\"127.0.0.1\",\"imap_port\":3143,\"imap_username\":\"$MAILBOX\",\"imap_password\":\"secret\",\"imap_use_ssl\":false}}" | id_of)
cat > inbox.json <<EOF
{"nodes":[
 {"id":"t1","type":"imapTrigger","position":{"x":0,"y":0},"data":{"label":"inbox","credentialId":"$CRED","pollIntervalMinutes":1}},
 {"id":"s1","type":"set","position":{"x":300,"y":0},"data":{"label":"received","mappings":[{"key":"date","value":"\$inbox.email.date"}]}}],
 "edges":[{"id":"e1","source":"t1","target":"s1"}]}
EOF
W=$(new_workflow "Inbox dates" inbox.json)
# Wait for the first poll (one to two minutes): it records the mailbox as it is and runs nothing.
python3 - "$MAILBOX" <<'PY'
import smtplib, sys
msg = ("From: Alerts <alerts@example.com>\r\nTo: %s\r\nSubject: disk full\r\n"
       "Date: Mon, 03 Nov 2025 10:00:00 -0000\r\n\r\nbody\r\n") % sys.argv[1]
with smtplib.SMTP("127.0.0.1", 3025) as smtp:
    smtp.sendmail("alerts@example.com", [sys.argv[1]], msg)
PY
# After the next poll:
RUN=$(curl -s "${H[@]}" "$HEYM/api/workflows/$W/history?limit=1" | python3 -c 'import json,sys;print(json.load(sys.stdin)["items"][0]["id"])')
curl -s "${H[@]}" "$HEYM/api/workflows/history/all/$RUN" | python3 -c 'import json,sys;print(json.load(sys.stdin)["outputs"])'

My backends ran in Europe/Tallinn (UTC+2 in November):

  • main: {'received': {'date': '2025-11-03T08:00:00+00:00'}}
  • This branch: {'received': {'date': '2025-11-03T10:00:00+00:00'}}

With the image's Europe/Berlin, main gives 09:00 for this date. Test: tests/test_email_payload_date.py, which pins TZ=Europe/Berlin.

2. The Error Handler fields in the docs and the DSL prompt do not exist

The node page and the DSL prompt described $errorHandler.error as the message and listed .errorNode, .errorNodeType and .timestamp. Those are the input body of the separate error workflow (error_workflow_runner.build_error_context). The node outputs {"error": {"node_id", "node_label", "node_type", "message"}}, which is also what its editor hint says ($error.message, $error.node_id, $error.node_label). A notification written from the DSL, as the AI builder writes it, renders the whole object. The page, the Slack page's example and the DSL's examples now use .error.message and .error.node_label. The node is unchanged.

cat > notice.json <<'EOF'
{"nodes":[
 {"id":"in_1","type":"textInput","position":{"x":0,"y":0},"data":{"label":"userInput","inputFields":[{"key":"text"}]}},
 {"id":"t1","type":"throwError","position":{"x":300,"y":0},"data":{"label":"checkOrder","errorMessage":"Order 42 not found"}},
 {"id":"eh","type":"errorHandler","position":{"x":0,"y":300},"data":{"label":"catchErrors"}},
 {"id":"s1","type":"set","position":{"x":300,"y":300},"data":{"label":"notice","mappings":[
   {"key":"documented","value":"Error in $catchErrors.errorNode: $catchErrors.error"},
   {"key":"corrected","value":"Error in $catchErrors.error.node_label: $catchErrors.error.message"}]}}],
 "edges":[{"id":"e1","source":"in_1","target":"t1"},{"id":"e2","source":"eh","target":"s1"}]}
EOF
W=$(new_workflow "Error notice" notice.json)
curl -s "${H[@]}" -H "X-Simple-Response: false" -X POST "$HEYM/api/workflows/$W/execute" -d '{"text":"x"}' \
  | python3 -c 'import json,sys;print(next(r["output"] for r in json.load(sys.stdin)["node_results"] if r["node_label"]=="notice"))'

Both versions print:

{'documented': 'Error in $catchErrors.errorNode: {"node_id": "t1", "node_label": "checkOrder", "node_type": "throwError", "message": "Order 42 not found"}', 'corrected': 'Error in checkOrder: Order 42 not found'}

Test: tests/test_error_handler_dsl_fields.py. It checks that every $errorHandler.error.<field> the prompt names is in the node's output, that no old name or bare $errorHandler.error is left, and that the prompt's notification example renders the failure.

3. The Data Table limit has no default of 100

The node page and the DSL prompt said dataTableLimit defaults to 100. The editor says "Leave empty for no limit", and the node limits only when the value is above 0, so a workflow built without the field got the whole table. The page and the prompt now say that.

TABLE=$(curl -s "${H[@]}" -X POST "$HEYM/api/data-tables" -d '{"name":"Orders","columns":[{"name":"n","type":"number"}]}' | id_of)
python3 -c 'import json;print(json.dumps([{"data":{"n":i}} for i in range(150)]))' > rows.json
curl -s -o /dev/null "${H[@]}" -X POST "$HEYM/api/data-tables/$TABLE/rows/bulk" -d @rows.json
cat > orders.json <<EOF
{"nodes":[
 {"id":"in_1","type":"textInput","position":{"x":0,"y":0},"data":{"label":"userInput","inputFields":[{"key":"text"}]}},
 {"id":"d1","type":"dataTable","position":{"x":300,"y":0},"data":{"label":"orders","dataTableId":"$TABLE","dataTableOperation":"getAll"}}],
 "edges":[{"id":"e1","source":"in_1","target":"d1"}]}
EOF
W=$(new_workflow "All orders" orders.json)
curl -s "${H[@]}" -X POST "$HEYM/api/workflows/$W/execute" -d '{"text":"x"}' | python3 -c 'import json,sys;print(json.load(sys.stdin)["orders"]["count"])'

Both versions print 150. Test: tests/test_data_table_limit_default_postgres.py.

4. Node pages that name outputs their nodes never return

I found these by comparing each node page and DSL section with the handler's return value; the DSL prompt was already right for all of them.

  • Crawler. The page listed $nodeLabel.body; the node returns html, url, status and, in extract mode, extracted. Its selector example had no name and no crawlerMode: "extract", and the node skips a selector without a name and extracts only in extract mode, so the example extracted nothing. The page now matches the handler, and the example extracts.
  • Slack, Discord and Telegram triggers. The pages listed $nodeLabel.triggered_by and $nodeLabel.trigger_node_id. They are run inputs (and reference/triggers.md, which describes run inputs, keeps them), but the trigger nodes copy only their own fields into their output, so both were always null.
  • Condition and Switch. The pages said the input passes through to the branch. They output only branch (and Switch its value), so $isLong.body.text or $input.body.text after a Condition is null; the earlier node's label still works.
  • Telegram. The page said $nodeLabel.status is "sent"; it is the HTTP status code of Telegram's response.

The Condition case on either version:

cat > cond.json <<'EOF'
{"nodes":[
 {"id":"in_1","type":"textInput","position":{"x":0,"y":0},"data":{"label":"userInput","inputFields":[{"key":"text"}]}},
 {"id":"c1","type":"condition","position":{"x":300,"y":0},"data":{"label":"isLong","condition":"$userInput.body.text.length > 1"}},
 {"id":"s1","type":"set","position":{"x":600,"y":0},"data":{"label":"probe","mappings":[
   {"key":"viaCondition","value":"$isLong.body.text"},{"key":"viaLabel","value":"$userInput.body.text"}]}}],
 "edges":[{"id":"e1","source":"in_1","target":"c1"},{"id":"e2","source":"c1","target":"s1","sourceHandle":"true"}]}
EOF
W=$(new_workflow "Condition output" cond.json)
curl -s "${H[@]}" -X POST "$HEYM/api/workflows/$W/execute" -d '{"text":"hello"}'; echo

prints {"probe":{"viaCondition":null,"viaLabel":"hello"}}.

The Crawler needs FlareSolverr and the triggers need a Slack, Discord or Telegram webhook, which I do not have here. tests/test_node_doc_outputs.py runs the Crawler page's own JSON example through the node with a fake FlareSolverr, and checks every field named in these pages' Overview rows against what the handlers return. On main's pages both Crawler tests fail, and so do 5 subtests for the triggers, Condition and Switch.

Review changes

  1. datatable-node.md says both: a node added from the canvas starts at 100, and empty or 0 returns every matching row.
  2. error-handler-node.md keeps $error.message as the message default the canvas pre-fills.
  3. reference/features.md: the Error Handler entry names the error fields instead of a timestamp, and the Condition and Switch entries say they output only their branch (Switch also its value).
  4. test_the_dsl_does_not_promise_a_default_limit moved to its own class, DataTableLimitDocsTests, so it runs without a database.

Tests check each: test_the_page_names_the_canvas_start_and_no_limit, ErrorHandlerPageTests, and FeaturesPageTests in tests/test_node_doc_outputs.py.

Checks

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

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

RFC 5322 gives "-0000" for a time in UTC whose sender's zone is unknown,
and Python's email.utils.formatdate() writes it by default.
parsedate_to_datetime returns such a date naive, and converting it to UTC
read it as the server's local time: the image and docker-compose set
TZ=Europe/Berlin, so 10:00 -0000 became 09:00Z in winter and 08:00Z in
summer. The IMAP, Gmail and Outlook triggers all build their payload with
email_payload; a naive date is now taken as UTC.
The node page and the AI builder's DSL said dataTableLimit defaulted to
100. The editor says "Leave empty for no limit" and the node limits only
when the value is above 0, so a workflow built without the field expecting
100 rows got the whole table (150 of 150 on a live instance). The docs and
the DSL now describe what the node does.
The node page and the AI builder's DSL described $errorHandler.error as
the message and listed .errorNode, .errorNodeType and .timestamp, which
are the body of the separate error workflow. The node outputs
{"error": {"node_id", "node_label", "node_type", "message"}}, as its
editor hint says, so a notification written from the DSL rendered as
'Error in $catchErrors.errorNode: {"node_id": ...}'. The docs, the Slack
page's example and the DSL examples now use .error.message and
.error.node_label.
…works

The node page listed $nodeLabel.body, which the node never returns: it
returns html, url, status and, in extract mode, extracted. Its selector
example had no name and no crawlerMode "extract", and the node skips a
selector without a name and extracts only in extract mode, so the example
extracted nothing. The page now matches the handler and the DSL prompt.
A test runs the page's example through the node with a fake FlareSolverr.
…turn

The Slack, Discord and Telegram trigger pages listed triggered_by and
trigger_node_id: they are run inputs, and the trigger nodes copy only
their own fields into the output, so both were always null. The
Condition and Switch pages said the input passes through to the branch;
they output only the branch (and Switch its value), so $cond.text and
$input.text after them are null. The Telegram page said status is
"sent"; it is the HTTP status code. The test now checks every field
these pages' Overview rows name against the node's output.
@ckakgun ckakgun added the next label Nov 22, 2026
@ckakgun

ckakgun commented Nov 22, 2026

Copy link
Copy Markdown
Collaborator

Thanks for this batch, the date fix and the handler checks are spot on 🙏

A few changes before we can merge:

  1. datatable-node.md: a Data Table node added from the canvas starts with dataTableLimit: 100 (NODE_DEFINITIONS.dataTable.defaultData), so dropping "default: 100" makes the page wrong for canvas users. Please say both: new canvas nodes start at 100, and empty or 0 returns every row.
  2. error-handler-node.md: the canvas pre-fills message with $error.message, so please keep that default on the message row.
  3. reference/features.md still has the old wording: line 127 lists a timestamp in the Error Handler output, and lines 195 and 201 say Condition and Switch pass the input through.
  4. test_the_dsl_does_not_promise_a_default_limit only reads the DSL prompt, but it sits in the Postgres test class and is skipped without a database. Please move it to its own class.

A Data Table node added from the canvas starts with dataTableLimit 100,
so the page now says both: new canvas nodes start at 100, and an empty
or 0 limit returns every row. The DSL check moves to its own test class,
so it runs without a database.
The canvas pre-fills message with $error.message, so the node page keeps
that default on the message row. The features reference listed a
timestamp in the node's output; it now names the error fields the node
returns.
The features reference said both nodes pass the input to the chosen
branch; they output only their branch (and Switch its value), as their
node pages now say.
@ersinkoc

Copy link
Copy Markdown
Contributor Author

Thanks! All four are in, as three follow-up commits:

  1. datatable-node.md now says a canvas node starts at 100 and that empty or 0 returns every row.
  2. The message row keeps $error.message as the canvas default.
  3. features.md: the Error Handler entry names the error fields, and Condition and Switch no longer say the input passes through.
  4. The DSL check is in its own class (DataTableLimitDocsTests) and runs without a database.

Each has a test. Full suite: 9820 passed.

@ckakgun

ckakgun commented Nov 22, 2026

Copy link
Copy Markdown
Collaborator

Thanks, all four are in 🙏

Two small things in the new features.md lines, then we can merge:

  1. Switch: "the value it matched" is not right for the default branch. value is what the expression evaluated to, so on default it matched no case.
  2. Error Handler: "Output is error with ..." leaves out message, which a canvas node always has because message is pre-filled with $error.message. Please add it, as the node page does.

Switch's value is what the expression evaluated to, so on default it
matched no case; the entry no longer says "the value it matched". The
Error Handler entry also names message, which a canvas node always has
since it pre-fills message with $error.message.
@ersinkoc

Copy link
Copy Markdown
Contributor Author

Both fixed in features.md: Switch now says value is what the expression evaluated to (on default it matched no case), and the Error Handler entry names message, which a canvas node pre-fills with $error.message. Tests check both lines; full suite 9821 passed.

@ckakgun
ckakgun merged commit a76ed28 into heymrun:main Nov 22, 2026
2 checks passed
@ckakgun

ckakgun commented Nov 22, 2026

Copy link
Copy Markdown
Collaborator

Thank you 💯

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