fix(14): cast companies-list id to Number to match resolve route's z.number() schema

companies.id is BIGINT and node-postgres serializes it as a string. The
manual-search fallback (D-05) fetches from this route and sends the id
straight through to POST /company-matches/[id]/resolve, whose Zod schema
requires a JS number with no coercion — every manual-search resolution was
rejected with 400. Every other PAX8 route in this phase already casts
bigint columns via Number(); this route was the one omission.

Found by code review (14-REVIEW.md, CR-01).
This commit is contained in:
lorentz 2026-07-11 15:16:38 -04:00
parent 1f5a65ecc1
commit d56db023be

View file

@ -10,7 +10,11 @@ export async function GET() {
const result = await postgresClient.query(
`SELECT id, company_name FROM companies WHERE is_active = true AND is_deleted = false ORDER BY company_name ASC`
);
return NextResponse.json(result.rows);
const companies = result.rows.map((row) => ({
id: Number(row.id),
company_name: row.company_name,
}));
return NextResponse.json(companies);
} catch (error) {
console.error('Error fetching companies list:', error);
return NextResponse.json({ error: 'Failed to fetch companies list' }, { status: 500 });