Skip to content

fix(api): quote camelCase identifiers + ParseIntPipe on route :id (Postgres)#1

Open
Danswar wants to merge 2 commits into
developfrom
fix/postgres-camelcase-and-parseint
Open

fix(api): quote camelCase identifiers + ParseIntPipe on route :id (Postgres)#1
Danswar wants to merge 2 commits into
developfrom
fix/postgres-camelcase-and-parseint

Conversation

@Danswar

@Danswar Danswar commented Jun 20, 2026

Copy link
Copy Markdown
Owner

Problem

A class of HTTP 500s on prod traces to the MySQL→Postgres migration. Postgres folds unquoted identifiers to lowercase and is stricter on function signatures, so raw-SQL fragments that worked on MySQL now error at runtime. Mapped from 7 days of prod Postgres logs:

  • invalid input syntax for type integer: "NaN" (94) — top volume
  • missing FROM-clause entry for table "userdata" (66)
  • column ... does not exist on camelCase columns (issueId, userDataId, linkId, organizationName)
  • function round(double precision, integer) does not exist

Changes

ParseIntPipe on route :id handlers (buy/sell/swap controllers — get/update/history):
A non-numeric :id made +idNaN, bound as an integer query param → 500. Now rejects with a proper 400.

Quote camelCase aliases/columns in raw query fragments:

  • support-issue.service.ts"userData", "organizationName", "issueId" (list search + message-stats subqueries)
  • deposit-route.service.ts"userData"."paymentLinksConfig" (payment-link key lookup)
  • bank-data.service.ts"userDataId" (metadata-less .update('bank_data') QB)
  • payment-link-payment.service.ts"linkId"/"maxId" (most-recent-payments subquery join)

Casing verified against the InitialSchema migration (source of truth for the actual column names).

ref-reward.service.ts — cast ROUND(SUM(...)::numeric, 0); Postgres has no round(double precision, integer) overload.

Scope

Limited to the confirmed serving-path 500s. Deliberately excludes the gs.service relation "sell" STI issue and the /gs/debug ad-hoc admin-SQL errors (admin-console only, not application queries).

Validation

  • ESLint clean; affected controller specs pass (ts-jest type-checks the stringnumber param change at call sites).
  • Build clean for the changed files. The only build errors are pre-existing baseline (eventsource / @opentelemetry/* deps not present locally; resolved by a fresh install in CI).

Yannick1712 and others added 2 commits June 22, 2026 14:19
…stgres)

Fixes a class of HTTP 500s introduced by the MySQL->Postgres migration.
Postgres folds unquoted identifiers to lowercase and is stricter on
function signatures, so raw-SQL fragments that worked on MySQL now error.

- buy/sell/swap controllers: add ParseIntPipe to the route `:id` handlers
  (get/update/history). A non-numeric `:id` made `+id` -> NaN, bound as an
  integer param -> `invalid input syntax for type integer: "NaN"` 500.
  Now rejects with 400 instead.
- support-issue, deposit-route, bank-data, payment-link-payment: quote the
  camelCase aliases/columns in raw query fragments (`"userData"`,
  `"issueId"`, `"userDataId"`, `"linkId"`, `"maxId"`,
  `"organizationName"`, `"paymentLinksConfig"`) so they resolve instead of
  folding to lowercase (`missing FROM-clause entry`, `column ... does not exist`).
- ref-reward: cast `ROUND(SUM(...)::numeric, 0)` — Postgres has no
  `round(double precision, integer)` overload.
@Danswar Danswar force-pushed the fix/postgres-camelcase-and-parseint branch from 04d82d1 to 6ffeacf Compare June 22, 2026 14:39
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.

2 participants