fix(invoiceintake): qualify order_by so Contact lookups by e-mail work #104

Merged
sharang merged 1 commits from fix/intake-contact-order into main 2026-10-29 11:38:47 +00:00
Owner

Backlog t53. breakpilot-invoice-intake fails every run (every 10 min, 144 ERROR lines in 24 h, handled: 0):

list Contact: HTTP 500: pymysql.err.OperationalError: (1052, "Column 'creation' in ORDER BY is ambiguous")

The supplier lookup lists Contacts filtered on the child table Contact Email; Frappe joins tabContact Email, and the bare order_by=creation asc exists in both tables. So nothing sent to invoice@ became an E Invoice Import / draft Purchase Invoice / ToDo.

Fix: list() orders by `tab<Doctype>`.`creation` asc.

Test: the fake ERP now answers like MariaDB (child-table filter + unqualified order_by → 500 with that error). Without the fix 6 intake tests fail, with it all pass (-race); golangci-lint 0 issues.

After merge: the intake image redeploys on the infra cluster; its next run works through every mail since INTAKE_SINCE (it keeps no state). Check in ERPNext: E Invoice Import, Purchase Invoice drafts, ToDo „prüfen“.

🤖 Generated with Claude Code

https://claude.ai/code/session_01KYcAAeTw22GE9QPzDM8yc4

Backlog t53. `breakpilot-invoice-intake` fails **every run** (every 10 min, 144 ERROR lines in 24 h, `handled: 0`): ``` list Contact: HTTP 500: pymysql.err.OperationalError: (1052, "Column 'creation' in ORDER BY is ambiguous") ``` The supplier lookup lists Contacts filtered on the child table **Contact Email**; Frappe joins `tabContact Email`, and the bare `order_by=creation asc` exists in both tables. So nothing sent to invoice@ became an E Invoice Import / draft Purchase Invoice / ToDo. **Fix:** `list()` orders by `` `tab<Doctype>`.`creation` asc ``. **Test:** the fake ERP now answers like MariaDB (child-table filter + unqualified order_by → 500 with that error). Without the fix 6 intake tests fail, with it all pass (`-race`); `golangci-lint` 0 issues. **After merge:** the intake image redeploys on the infra cluster; its next run works through every mail since `INTAKE_SINCE` (it keeps no state). Check in ERPNext: E Invoice Import, Purchase Invoice drafts, ToDo „prüfen“. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01KYcAAeTw22GE9QPzDM8yc4
sharang added 1 commit 2026-10-29 11:34:14 +00:00
fix(invoiceintake): qualify order_by so Contact lookups by e-mail work
ci / shared (pull_request) Successful in 14s
ci / test (pull_request) Successful in 26m55s
ci / image (pull_request) Skipped
7857fb4f09
Every intake run failed with "list Contact: HTTP 500: (1052, Column
'creation' in ORDER BY is ambiguous)": the supplier lookup filters on the
child table Contact Email, Frappe joins it, and the bare order_by column
exists in both tables. Nothing sent to invoice@ became a draft (t53).
order_by is now `tab<Doctype>`.`creation`; the fake ERP in the tests
refuses an unqualified one with a child-table filter, like MariaDB.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KYcAAeTw22GE9QPzDM8yc4
sharang merged commit ee8ae87917 into main 2026-10-29 11:38:47 +00:00
Sign in to join this conversation.