Skip to content

Commit b825459

Browse files
committed
fix(knowledge): cast the stale-sweep cutoff so the member-sync scheduler stops failing
1 parent 180cb12 commit b825459

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎apps/sim/lib/knowledge/connectors/member-observations.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,13 @@ export async function sweepStaleMemberObservations(now: Date): Promise<StaleMemb
446446
${MEMBER_OBSERVATION_STALE_AFTER_HOURS} * INTERVAL '1 hour',
447447
2 * ${knowledgeConnector.syncIntervalMinutes} * INTERVAL '1 minute'
448448
)`
449-
const cutoff = sql`${sql.param(now, knowledgeConnectorMember.lastStartedAt)} - ${staleWindow}`
449+
/**
450+
* The bound instant is cast: in `$now - GREATEST(...)` Postgres cannot see a
451+
* timestamp on either side and resolves the subtraction as interval
452+
* arithmetic, which makes the cutoff an interval and every comparison below
453+
* fail with "operator does not exist: timestamp > interval".
454+
*/
455+
const cutoff = sql`${sql.param(now, knowledgeConnectorMember.lastStartedAt)}::timestamp - ${staleWindow}`
450456
const staleMembers = await db
451457
.select({
452458
id: knowledgeConnectorMember.id,

0 commit comments

Comments
 (0)