fix(server): error-handling and config-validation batch #6
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/server-smallfixes"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Four small fixes from the repo-wide review, one commit each:
Position-open 409 narrowed. The unique-index backstop caught ANY error and reported "position already open" — disk-full or closed-DB errors became 409s. Now only
SqliteError.code === "SQLITE_CONSTRAINT_UNIQUE"(verified empirically against the real partial index) maps to 409; everything else propagates as 500. The race-past-the-pre-check path is covered by a test that stubs the pre-check to miss and hits the real index.GET /api/positionsfetches prices in parallel, deduped per(instrumentClass, symbol)(same pattern asOutcomeTracker.fill). Per-position error semantics unchanged: a failed price still yieldscurrentPrice: nullfor that position only.Config validation.
CATALYST_PROVIDERis validated against the allowed union (typos warn loudly and fall back tononeinstead of silently degrading);port/pollIntervalMs/discoveryIntervalMs/requestTimeoutMsusenumPossoPORT=""no longer yields port 0 andPOLL_INTERVAL_MS=0no longer spins;confirmationWindowis validated against the YahooCHART_INTERVALSviaresolveChartInterval()(warn + fall back to15m) — Binance keeps the raw value since it has its own interval grammar.PUT /api/settings400s return a generic{ error: "invalid settings" }instead of leaking zod issue internals; issues are logged server-side.Tests: 56 files / 320 passing, typecheck clean.
Every other route returns a generic { error } shape; the settings route echoed parsed.error.issues to the client. Return the generic error and log the issues server-side instead.d459bd2049tod5cff16d6a