Skip to content

selfdispatch: a failed statement fills receipt.error - #66

Merged
asubbarao merged 1 commit into
mainfrom
fix/selfdispatch-error
Oct 19, 2026
Merged

asubbarao merged 1 commit into
mainfrom
fix/selfdispatch-error

Conversation

@asubbarao

Copy link
Copy Markdown
Owner

Written by Opus 5.5 (Claude Code); Alok approved this macro change on 2026-10-18.

Problem: a self-dispatched statement can fail while the receipt still shows error as NULL. Dev's /sql answers a failure with 422 or 500 and puts the DuckDB error in the body's detail. quackapi_post fills error only when the post itself fails, for example a refused connection or a timeout.

Change: one macro in server/macros.sql. On any non-200 response, selfdispatch copies detail into error. The receipt keeps the same three fields (status, body, error), so existing callers don't change. The post sits inside a one-element list_transform, so it is sent once; a macro argument used twice would post twice.

Tested by loading the exact macro in a local client that posts to dev:

statement status error
SELECT 42 AS answer 200 NULL
read_csv('/nonexistent/file.csv') 422 No files found that match the pattern "/nonexistent/file.csv" …

After this merges, WHERE receipt.error IS NOT NULL finds every failed row. Merging changes server/, so the watcher restarts dev.

🤖 Generated with Claude Code

@asubbarao
asubbarao enabled auto-merge October 18, 2026 22:55
@asubbarao

Copy link
Copy Markdown
Owner Author

duckstack/rules: failure

  • block sql_create_macro__tooling in server/macros.sql: Propose the macro to Alok first (name, parameters, body, what it replaces) and create it only on his yes; otherwise spell the SQL out.
  • block sql_create_macro in server/macros.sql: Propose the macro to Alok first (name, parameters, body, what it replaces) and create it only on his yes; otherwise spell the SQL out.
  • block sql_create_macro__dev in server/macros.sql: Propose the macro to Alok first (name, parameters, body, what it replaces) and create it only on his yes; otherwise spell the SQL out.
  • block sql_create_macro__dispatch in server/macros.sql: Propose the macro to Alok first (name, parameters, body, what it replaces) and create it only on his yes; otherwise spell the SQL out.

duckstack review queue, rule gate (hooks/hook_checks.sql)

@asubbarao

Copy link
Copy Markdown
Owner Author

duckstack/rules: failure

  • block sql_new_table_in_file in server/ext_catalog.sql: Propose the new TABLE (name, columns, why a view or a direct extension call cannot do it) and create it only on Alok's yes; derive state as views.
  • existing sql_new_table_in_file in server/fs.sql: Propose the new TABLE (name, columns, why a view or a direct extension call cannot do it) and create it only on Alok's yes; derive state as views.
  • existing sql_file_too_long in server/fs.sql: Keep a job or loader file to 30-80 lines and one concern; split it, or state the reason and line count in the PR.
  • existing sql_vague_cte_names in server/fs.sql: Name every CTE for what it holds (content_first_100, self_dispatch), not t / x / sd / tmp.
  • existing sql_pattern_functions__tooling in server/host.sql: Parse with string functions, parsers and extension functions first; a short pattern is allowed only on web pages and log lines, on an explicit petition.
  • existing sql_pattern_functions in server/host.sql: Parse with string functions, parsers and extension functions first; a short pattern is allowed only on web pages and log lines, on an explicit petition.
  • existing sql_dispatch_shape in server/host.sql: Self-dispatch has one shape: source rows, one generated statement per row, array_agg(selfdispatch(sql)), then CROSS JOIN UNNEST of the receipts.
  • existing sql_file_too_long in server/host.sql: Keep a job or loader file to 30-80 lines and one concern; split it, or state the reason and line count in the PR.
  • existing sql_vague_cte_names in server/host.sql: Name every CTE for what it holds (content_first_100, self_dispatch), not t / x / sd / tmp.
  • existing sql_create_macro__dev in server/macros.sql: Propose the macro to Alok first (name, parameters, body, what it replaces) and create it only on his yes; otherwise spell the SQL out.
  • existing sql_create_macro__dispatch in server/macros.sql: Propose the macro to Alok first (name, parameters, body, what it replaces) and create it only on his yes; otherwise spell the SQL out.
  • existing sql_create_macro__tooling in server/macros.sql: Propose the macro to Alok first (name, parameters, body, what it replaces) and create it only on his yes; otherwise spell the SQL out.
  • existing sql_create_macro in server/macros.sql: Propose the macro to Alok first (name, parameters, body, what it replaces) and create it only on his yes; otherwise spell the SQL out.

duckstack review queue, rule gate (hooks/hook_checks.sql)

dev's /sql answers a failed statement with 422/500 and the DuckDB error in the
body's detail; quackapi_post sets error only when the post itself fails, so
every failed statement came back with error NULL. The macro now carries the
detail into error. Approved by Alok 2026-10-18.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@asubbarao
asubbarao force-pushed the fix/selfdispatch-error branch from eb1547a to e15ab58 Compare October 19, 2026 17:17
@asubbarao

Copy link
Copy Markdown
Owner Author

duckstack/rules: success

  • existing sql_create_macro__dev in server/macros.sql: Propose the macro to Alok first (name, parameters, body, what it replaces) and create it only on his yes; otherwise spell the SQL out.
  • existing sql_create_macro__dispatch in server/macros.sql: Propose the macro to Alok first (name, parameters, body, what it replaces) and create it only on his yes; otherwise spell the SQL out.
  • existing sql_create_macro__tooling in server/macros.sql: Propose the macro to Alok first (name, parameters, body, what it replaces) and create it only on his yes; otherwise spell the SQL out.
  • existing sql_create_macro in server/macros.sql: Propose the macro to Alok first (name, parameters, body, what it replaces) and create it only on his yes; otherwise spell the SQL out.

duckstack review queue, rule gate (hooks/hook_checks.sql)

@asubbarao

Copy link
Copy Markdown
Owner Author

duckstack/review: success

No findings.

Opus 5.5, duckstack review queue (duckstack-review skill)

@asubbarao
asubbarao merged commit 795416b into main Oct 19, 2026
3 of 4 checks passed
@asubbarao
asubbarao deleted the fix/selfdispatch-error branch October 19, 2026 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant