Metabot question links silently drop date filters (during / between absolute-datetime), showing wrong totals
Version: Metabase OSS v0.63.18 (2ba2485c), Docker metabase/metabase@sha256:1160b570cb11c107bce00e71293552df8a8363e01a32c2c7a048cee002dc8a73. PostgreSQL 17.11 data source. The application DB is Postgres.
Metabot: BYOK OpenRouter. Reproduced with openai/gpt-5.6-luna and openai/gpt-5.6-sol, so it does not depend on the model.
Summary
When Metabot answers a date-range question, it returns a /question#<base64> link whose legacy dataset_query filters the date as ["during", <field>, "2026-08-01", "month"] or ["between", <field>, ["absolute-datetime", …], ["absolute-datetime", …]].
When that query runs (the UI opening the link, or POST /api/dataset), the date clause is dropped without an error. The generated SQL has no date condition, so the user sees all-time totals presented as the answer for that month.
A clause Metabase cannot process should fail loudly instead of disappearing.
Minimal reproduction (synthetic data)
Table reporting.agent_runs_daily(client_id text, run_date date, status text, run_count int), several months of daily rows.
Run this legacy query through POST /api/dataset (field ids replaced by names for readability):
{"database": 2, "type": "query", "query": {
"source-table": <agent_runs_daily>,
"aggregation": [["sum", ["field", <run_count>, null]]],
"breakout": [["field", <status>, null]],
"filter": ["and", ["=", ["field", <client_id>, null], "client_b"],
["during", ["field", <run_date>, null], "2026-08-01", "month"]]}}Filter on run_date |
Result (succeeded) | Date condition present in the SQL WHERE |
|---|---|---|
Expected (run_date >= '2026-08-01' AND run_date < '2026-09-01') |
145 (cancelled 4, failed 15) | yes |
A: ["during", f, "2026-08-01", "month"] (as Metabot emits) |
1,604 (all months) | no |
B: ["between", f, ["absolute-datetime","2026-08-01","day"], ["absolute-datetime","2026-08-31","day"]] (as Metabot emits) |
1,604 | no |
C: ["between", f, "2026-08-01", "2026-08-31"] |
145 | yes |
D: [">=", f, "2026-08-01"] + ["<", f, "2026-09-01"] |
145 | yes |
Raw output:
truth (admin SQL): [['cancelled', 4], ['failed', 15], ['succeeded', 145]]
A during (as Metabot emits) | status completed | rows [['cancelled', 99], ['failed', 149], ['running', 2], ['succeeded', 1604]] | date in WHERE: False
B between absolute-datetime (as Metabot emits) | status completed | rows [['cancelled', 99], ['failed', 149], ['running', 2], ['succeeded', 1604]] | date in WHERE: False
C between plain strings | status completed | rows [['cancelled', 4], ['failed', 15], ['succeeded', 145]] | date in WHERE: True
D >= and < (control) | status completed | rows [['cancelled', 4], ['failed', 15], ['succeeded', 145]] | date in WHERE: TrueThrough Metabot (end to end)
- Connect any supported OpenRouter model. Ask: "Write a SQL query against that returns total agent runs per status for client_b in August 2026, run it, and state the exact number per status."
- Metabot returns a question link. Open it.
- Actual: the filter bar shows only "Client ID is client_b", and the table shows succeeded 1,604 (screenshot available on request).
- Expected: a date filter for August 2026 is present, and succeeded is 145.
Impact
Silent wrong answers from the built-in AI assistant: the result looks authoritative, and nothing tells the user a filter was lost. Filters on an exact date (["=", f, "2026-09-01"]) are not affected.
Suggested fix
- Either serialise Metabot's MBQL 5 temporal filters into legacy clauses that the legacy path supports (C or D above), or keep the link in MBQL 5.
- And make the legacy normaliser reject unsupported filter clauses rather than dropping them.
Source: metabase/metabase