Skip to content

fix: include the entire end day in executions date-range filter (#2075) - #2239

Merged
yannickmonney merged 1 commit into
mainfrom
tale/xs7dnyk1vc916sed867ggwahn189bjhm
Jun 29, 2026
Merged

yannickmonney merged 1 commit into
mainfrom
tale/xs7dnyk1vc916sed867ggwahn189bjhm

Conversation

@larryro

@larryro larryro commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Closes #2075

Problem

The Executions date-range filter excluded the entire end day. Picking "Today" (or any range whose end is today) returned essentially no rows.

Root cause was a date-to-timestamp collapse:

  • The table serialized the picker to value as a bare YYYY-MM-DD string with no end-of-day handling.
  • The backend ran new Date("2026-06-24").getTime(), which JS parses as UTC midnight, then filtered with .lte("startedAt", toDate).
  • Since startedAt is an epoch timestamp, any run later than 00:00 UTC on the end day failed the predicate and was dropped.

A secondary skew existed because the picker computed startOfDay in local time while the backend interpreted the serialized date as UTC.

Fix

Make the picker boundaries and the backend parsing agree on a single, fully-inclusive convention:

  • Frontend (executions-table.tsx): serialize the actual full-day boundary instants — startOfDay(from).toISOString() and endOfDay(to).toISOString() — instead of a bare date. This captures the user’s local-day boundaries as absolute instants, fixing both the end-day collapse and the local/UTC skew.
  • Backend (date_range_filter.ts, new shared helper): parseExecutionDateBounds parses those instants directly. For backward compatibility with older links that carry a bare YYYY-MM-DD dateTo, it expands the value to the last millisecond of that UTC day so the end day stays inclusive. Applied to all three consumers (list_executions, list_executions_cursor, list_executions_paginated_native) so they no longer diverge.

Tests

  • New date_range_filter.test.ts covering full-ISO parsing, bare-date end-of-day expansion, the midday-run regression, and invalid input.
  • Existing backend and executions-table tests pass; tsc --noEmit and oxlint --type-aware are clean.

@larryro

larryro commented Jun 28, 2026

Copy link
Copy Markdown
Contributor Author

Desk Review — #2075 (Executions date-range end-day exclusion)

Verdict: READY TO MERGE ✅

Reviewed the whole implementation (not just the diff) over two rounds: 5 breadth subagents (correctness / robustness / elegance / tests / resolution+consumers) and a confirmation pass on the one potentially-blocking finding.

Evidence

  • CI: all green. All required checks pass (Unit, Type check, Lint, Format, Knip, Build platform/convex, Playwright ×16, Smoke test, Opengrep/Trivy scans, etc.). The only non-pass entries are appropriately skipping fork-PR/container jobs.
  • Tests: pass locally. cd services/platform && bunx vitest --run --project server convex/workflows/executions → 9 files, 70 tests passed. The new date_range_filter.test.ts directly asserts the Bug: Executions date-range filter excludes the entire end day (UTC-midnight collapse) — "Today" returns no rows #2075 regression (midday run on a bare end-date is now included).

Why it's correct

  • Frontend (executions-table.tsx) now serializes the picker selection as absolute instants — startOfDay(from).toISOString() / endOfDay(to).toISOString() — fixing both the end-day collapse and the local↔UTC skew. The parseISO redisplay round-trip stays correct.
  • New parseExecutionDateBounds parses ISO instants directly; the ^\d{4}-\d{2}-\d{2}$ guard means full ISO instants are not given the +DAY_MS-1 expansion, while legacy bare-date dateTo is — and the asymmetry (bare dateFrom left at UTC-midnight) is the right behavior. Epoch arithmetic is DST/overflow-safe.
  • All three execution-listing paths now route through the helper — list_executions, list_executions_cursor, list_executions_paginated_native. Every entry point (workflow_executions/queries.ts, internal_queries.ts, and the REST API in rest_api.ts) lands in one of these; no remaining raw new Date(args.dateTo).getTime() or bare-date formatISO. Removed formatISO import is clean (Knip/Lint green).

Non-blocking notes (optional, do not gate merge)

  1. Malformed-date degradation: a garbage dateFrom/dateTo (only reachable via hand-crafted REST/URL input — the UI never emits one) yields undefined → the date filter is silently dropped. Confirmed this is not a data-disclosure issue: results stay scoped by wfDefinitionId + org (callerOrgId post-filter in internal_queries.ts, RLS in rls_rules.ts). The sibling agent_tools/documents/helpers/list_documents.ts instead throws on invalid dates; harmonizing is a possible future hardening.
  2. Test gaps (minor): no explicit assertion that a bare dateFrom is left un-expanded, and no dateFrom-only / mixed-format cases; the helper is otherwise well covered and the predicate paths are exercised by existing suites.
  3. Style: DAY_MS constant vs the raw 86_400_000 literal used in list_documents.ts — cosmetic.

None of the above blocks merge. The fix is focused, well-tested, and fully resolves the reported issue.

@yannickmonney
yannickmonney merged commit da2e833 into main Jun 29, 2026
51 checks passed
@yannickmonney
yannickmonney deleted the tale/xs7dnyk1vc916sed867ggwahn189bjhm branch June 29, 2026 17:04
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.

Bug: Executions date-range filter excludes the entire end day (UTC-midnight collapse) — "Today" returns no rows

2 participants