porsager / porsager/postgres

Better error message for undefined values

Open
#380 8 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
JavaScript
Stars
8.7k
Forks
374
Avg merge
11d 16h
Merged PRs (30d)
1

Description

Hello,

if possible I think it would be great if you could get better error messages if you accidentially pass undefined as parameter. Especially the query and the arguments would probably be helpful. Currently it seems like you get something like the following:

May 25 22:13:53 arch-luks2 node[11410]:       throw Errors.generic('UNDEFINED_VALUE', 'Undefined values are not allowed')
May 25 22:13:53 arch-luks2 node[11410]:                    ^
May 25 22:13:53 arch-luks2 node[11410]: Error: UNDEFINED_VALUE: Undefined values are not allowed
May 25 22:13:53 arch-luks2 node[11410]:     at handleValue (/opt/projektwahl-lit-production/node_modules/postgres/src/types.js:84:20)
May 25 22:13:53 arch-luks2 node[11410]:     at stringifyValue (/opt/projektwahl-lit-production/node_modules/postgres/src/types.js:114:5)
May 25 22:13:53 arch-luks2 node[11410]:     at stringify (/opt/projektwahl-lit-production/node_modules/postgres/src/types.js:101:16)
May 25 22:13:53 arch-luks2 node[11410]:     at fragment (/opt/projektwahl-lit-production/node_modules/postgres/src/types.js:120:10)
May 25 22:13:53 arch-luks2 node[11410]:     at stringifyValue (/opt/projektwahl-lit-production/node_modules/postgres/src/types.js:111:30)
May 25 22:13:53 arch-luks2 node[11410]:     at stringify (/opt/projektwahl-lit-production/node_modules/postgres/src/types.js:101:16)
May 25 22:13:53 arch-luks2 node[11410]:     at fragment (/opt/projektwahl-lit-production/node_modules/postgres/src/types.js:120:10)
May 25 22:13:53 arch-luks2 node[11410]:     at stringifyValue (/opt/projektwahl-lit-production/node_modules/postgres/src/types.js:111:30)
May 25 22:13:53 arch-luks2 node[11410]:     at stringify (/opt/projektwahl-lit-production/node_modules/postgres/src/types.js:101:16)
May 25 22:13:53 arch-luks2 node[11410]:     at fragment (/opt/projektwahl-lit-production/node_modules/postgres/src/types.js:120:10)
May 25 22:13:53 arch-luks2 node[11410]:   originCache.set(xs, new Error())
May 25 22:13:53 arch-luks2 node[11410]:                       ^
May 25 22:13:53 arch-luks2 node[11410]: Error
May 25 22:13:53 arch-luks2 node[11410]:     at cachedError (/opt/projektwahl-lit-production/node_modules/postgres/src/query.js:166:23)
May 25 22:13:53 arch-luks2 node[11410]:     at Query (/opt/projektwahl-lit-production/node_modules/postgres/src/query.js:36:24)
May 25 22:13:53 arch-luks2 node[11410]:     at sql3 (/opt/projektwahl-lit-production/node_modules/postgres/src/index.js:105:11)
May 25 22:13:53 arch-luks2 node[11410]:     at <anonymous> (/opt/projektwahl-lit-production/src/server/entities.ts:184:27)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing undefined-value handling in src/types.js, then inspect the query construction paths shown in src/query.js and src/index.js. Compare the current error path with the requested query and argument context; done means undefined parameters produce a more useful error while preserving existing behavior and tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs, postgresql
Domain
backend, databases
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.