Reference
Errors
The errors the NordBase libraries raise, what causes each one, what to do about it, and which failures are retried for you.
The libraries turn what the Database sends back into a small set of named errors. The names are the same in every library.
Connection and query errors
| Library error | What happened | What the Database sends | What to do |
|---|---|---|---|
AuthenticationError | Wrong Credential id or secret, or the Credential was revoked or has expired | SQLSTATE 28P01, MongoDB error 18 | Check NORDBASE_URL is complete and current. After a rotation, deploy the new secret before the overlap ends. Check expires_at, and if the Credential has allowed_regions, that you connect to one of those Regions' Endpoints |
PermissionError | The Credential's Permission set does not allow this statement or command | SQLSTATE 42501, MongoDB error 13 | Run select nordbase.whoami() to see which Credential and preset you are using. Change its Grants (takes effect within 5 seconds) or use a Credential meant for this job |
ReadOnlyLockError | Storage is full. Reads work, Writes are refused | SQLSTATE 42501 on a Write, with nordbase.status() showing read_only_lock true | Make room: a larger Plan, one Replica fewer, or a Database deleted. The lock lifts at the next storage measurement; they run every 5 minutes. See Plans and limits |
TooManyConnectionsError | Every connection your Plan allows is in use | SQLSTATE 53300 | Lower each process's pool size, close idle connections, or move to a Plan with more connections |
TimeoutError | A statement ran longer than 30 seconds on the routed port, 5432 | SQLSTATE 57014 | Add an index, page through large results with limit, or split the work. Run long migrations on the Direct port, 5433 |
ConnectionError | The Endpoint could not be reached, even after retries. Usually a Failover or a Router restart | Connection errors, SQLSTATE class 08 | Retry later. If the error says a Write's outcome is unknown, check whether it was applied before you run it again |
The 30-second limit on the routed port will be configurable per Credential later.
When PermissionError and ReadOnlyLockError both arrive as 42501, the library tells them apart by calling nordbase.status(), so you get the right one.
Document Databases
| Library error | What happened | What to do |
|---|---|---|
UnsafeFilterError | A filter, update or pipeline contained an operator object that came in as data, a refused operator ($where, $function, $accumulator) or a bad field name. Nothing was sent | Write operators with op.* helpers and never pass request JSON as a filter. See Document Databases |
Refused before sending
Some mistakes are caught in your process, before anything reaches the Database:
- A plain string where a template is expected. The error shows the safe form. See Safe SQL.
- An empty name or a name with a NUL character in
sql.id. - A builder
updateordeletewithout a filter and without.all(). - An unknown table or column in the builder, or a row that does not match its table's types or your schema.
Throttling is not an error
When an Allowance is used up, the Database gets slower. Nothing raises an error, and no query fails because of the Throttle. See Plans and limits.
Retries
Libraries retry only before a statement is sent: while getting a connection that is refused, reset or failing over, for up to 30 seconds. A statement that was sent and then lost its connection is never sent again, Read or Write, because a Read can call a function that writes. The error then says the outcome is unknown; check before you retry yourself.
Checking from your code
Every SQL Database has two functions in schema nordbase that any Credential can call:
| Function | Returns, as jsonb |
|---|---|
nordbase.status() | read_only_lock, throttled, plan, and for Reads, Writes and Egress the amount used this month and the Allowance |
nordbase.whoami() | The Credential id, its Permission set preset and its expiry |
const [{ status }] = await db.sql`select nordbase.status() as status`
const [{ me }] = await db.sql`select nordbase.whoami() as me`[row] = db.sql(t"select nordbase.status() as status, nordbase.whoami() as me")-- From psql or any SQL client
select nordbase.status(), nordbase.whoami();Use nordbase.status() in a health check to warn before an Allowance runs out, and nordbase.whoami() when a PermissionError surprises you.
Management API errors
The management API answers errors as application/problem+json with a stable code, such as pool_exceeded or outside_recovery_window. See the API reference.