GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — fix(v2): give the keyset cursor's timestamp an explicit SQL type by waleedlatif1 · Pull Request #6636 · simstudioai/sim Conversation
Collaborator
The defectEvery v2 collection hands back a The keyset compares millisecond-truncated timestamps on both sides:
The cursor value was never unvalidated — a non-string or unparseable date is already rejected as a 400 by Not a regression from the recent v2 work
The fixCast the bound value to the column's own SQL type, inside sql`date_trunc('milliseconds', cast(${sql.param(date, column)} as ${sql.raw(column.getSQLType())}))` Derived from the column rather than hardcoded The millisecond truncation is unchanged. It is load-bearing: Postgres stores microseconds, a cursor value round-trips through a millisecond-only JS Affected sortsEvery keyset containing a timestamp key — 7 collections, 15 sorts. Default sorts in bold.
Not affected at all:
I swept every Verification
Skill
Note for a follow-up (not in this PR)
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Handing back the `nextCursor` from any timestamp-sorted v2 list and passing it straight in returned 500. The keyset compares millisecond-truncated timestamps on both sides, and the bound cursor value went out as a bare placeholder — which Postgres types as `unknown`. `date_trunc` is overloaded across `timestamp`, `timestamptz`, and `interval`, so `date_trunc(unknown, unknown)` matched no single candidate and the statement failed outright. The value was already validated; it just carried no type. Cast it to the column's own SQL type inside `timestampKey`, so all twelve call sites across six modules inherit the fix. Derived from the column rather than hardcoded, which keeps a `timestamptz` column's offset honoured too. The millisecond truncation is unchanged — it is what stops the page's own last row being re-admitted.
|
There was an error while loading. Please reload this page.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
PR SummaryMedium Risk Overview
Tests assert the cast in v2 API conventions docs (skill + command copies) record this as a fifth incident class, extend the “no caller 500” checklist for SQL-function arguments, and note that SQL-shape changes need real DB execution—not only unit tests. Reviewed by Cursor Bugbot for commit f27c7d6. Configure here. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Greptile SummaryThe PR fixes timestamp-based keyset pagination by explicitly casting bound cursor timestamps to each column’s PostgreSQL type.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| apps/sim/lib/api/list-query.ts | Adds a column-derived SQL cast around validated timestamp cursor parameters so PostgreSQL can resolve the overloaded date_trunc call. |
| apps/sim/lib/api/list-query.test.ts | Pins timestamp and timestamptz cast rendering and adds a guard against bare bound parameters inside SQL functions. |
| .agents/skills/v2-api-conventions/SKILL.md | Documents the timestamp-cursor incident and the requirement to type bound values passed to SQL functions. |
Reviews (2): Last reviewed commit: "fix(v2): give the keyset cursor's timest..." | Re-trigger Greptile
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@cursor review |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit f27c7d6. Configure here.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
f27c7d6e
Deployed
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.