Skip to content

Commit 77d4017

Browse files
committed
fix: convert bigint advisory_package ids to number explicitly (CM-1258)
Signed-off-by: Uroš Marolt <uros@marolt.me>
1 parent 1326a76 commit 77d4017

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

  • services/libs/data-access-layer/src/packages

services/libs/data-access-layer/src/packages/osv.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,13 @@ export async function findRemovedAdvisoryPackageIds(
184184
`,
185185
{ advisoryId, presentAdvisoryPackageIds },
186186
)
187-
return rows.map((r: { id: number }) => r.id)
187+
// advisory_packages.id is bigint (oid 20) — the pg connection only installs a
188+
// numeric type parser for int4 (services/libs/database/src/connection.ts:84-85),
189+
// so node-pg returns this column as a string. Convert explicitly so the
190+
// declared number[] return type is actually true — a bare cast would leave the
191+
// subtraction-based sort in upsertAdvisory.ts relying on implicit string-to-
192+
// number coercion, which loses precision once ids exceed Number.MAX_SAFE_INTEGER.
193+
return rows.map((r: { id: string }) => Number(r.id))
188194
}
189195

190196
// Diff-based upsert + soft-delete for OSV-owned advisory_affected_ranges rows.

0 commit comments

Comments
 (0)