fix(api): quote camelCase identifiers + ParseIntPipe on route :id (Postgres)#1
Open
Danswar wants to merge 2 commits into
Open
fix(api): quote camelCase identifiers + ParseIntPipe on route :id (Postgres)#1Danswar wants to merge 2 commits into
Danswar wants to merge 2 commits into
Conversation
…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.
04d82d1 to
6ffeacf
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 volumemissing FROM-clause entry for table "userdata"(66)column ... does not existon camelCase columns (issueId,userDataId,linkId,organizationName)function round(double precision, integer) does not existChanges
ParseIntPipe on route
:idhandlers (buy/sell/swapcontrollers — get/update/history):A non-numeric
:idmade+id→NaN, 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— castROUND(SUM(...)::numeric, 0); Postgres has noround(double precision, integer)overload.Scope
Limited to the confirmed serving-path 500s. Deliberately excludes the
gs.servicerelation "sell"STI issue and the/gs/debugad-hoc admin-SQL errors (admin-console only, not application queries).Validation
string→numberparam change at call sites).eventsource/@opentelemetry/*deps not present locally; resolved by a fresh install in CI).