Skip to content
NordBaseDocs

Search the docs

Find a page or a section of the NordBase docs

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 errorWhat happenedWhat the Database sendsWhat to do
AuthenticationErrorWrong Credential id or secret, or the Credential was revoked or has expiredSQLSTATE 28P01, MongoDB error 18Check 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
PermissionErrorThe Credential's Permission set does not allow this statement or commandSQLSTATE 42501, MongoDB error 13Run 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
ReadOnlyLockErrorStorage is full. Reads work, Writes are refusedSQLSTATE 42501 on a Write, with nordbase.status() showing read_only_lock trueMake 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
TooManyConnectionsErrorEvery connection your Plan allows is in useSQLSTATE 53300Lower each process's pool size, close idle connections, or move to a Plan with more connections
TimeoutErrorA statement ran longer than 30 seconds on the routed port, 5432SQLSTATE 57014Add an index, page through large results with limit, or split the work. Run long migrations on the Direct port, 5433
ConnectionErrorThe Endpoint could not be reached, even after retries. Usually a Failover or a Router restartConnection errors, SQLSTATE class 08Retry 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 errorWhat happenedWhat to do
UnsafeFilterErrorA 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 sentWrite 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 update or delete without 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:

FunctionReturns, 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
ts
const [{ status }] = await db.sql`select nordbase.status() as status`
const [{ me }] = await db.sql`select nordbase.whoami() as me`
python
[row] = db.sql(t"select nordbase.status() as status, nordbase.whoami() as me")
sql
-- 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.