Errors and Troubleshooting
Diagnose relational request failures using SDK response details, schema checks, and DDS authorization context.
Row Operation Errors
Normal database HTTP responses produce an envelope with data, error, count, status, and statusText. Check error before using data. Input validation, transport, cancellation, and response parsing can throw.
Handle both response errors and thrown failures:
try {
const { data, error } = await client
.from("todos")
.insert({ title: "Write documentation" });
if (error) {
console.error("Message:", error.message);
console.error("HTTP status:", error.status);
console.error("Code:", error.code);
console.error("Details:", error.details);
console.error("Hint:", error.hint);
} else {
console.log(data);
}
} catch (error) {
console.error("Request failed:", error);
}
A RelationalDatabaseError can provide message, status, code, details, and hint. Some fields can be absent. Use throwOnError() to handle database HTTP error responses as thrown RelationalDatabaseError instances.
For insert and upsert failures, check required columns, supplied data types, primary or unique keys, and any conflict column. For updates and deletions, check the target relation and filters.
Query Errors
Check the following when a query fails:
- The table or view exists in the client’s active schema.
- Relation and column names match the database identifiers.
- The projection and filter operators are valid for the query.
- Related-table queries use relationships supported by the service.
- DDS permits the requested objects, columns, and rows.
single() and maybeSingle() return an object for exactly one row and null for other array lengths in this SDK. A null result alone is not an HTTP authorization error.
For cache queries, inspect result.offline and handle unsupported local projections or incomplete targets. See Access Data Offline in JavaScript Applications.
Authentication and DDS Authorization Errors
The client request includes the project API key and, for authenticated access, a user JWT. ORDS validates the request, resolves the project and schema, and verifies the JWT when supplied.
Invalid or expired credentials cause the request to fail before database SQL runs.
For each request, the service creates or refreshes an End User Security Context from server-verified values. These values include the application-user identity, project identifier, request service and operation, and allowed Data Roles.
Oracle DeepSec evaluates Data Grants against the active Data Roles and context attributes. A matching Data Grant permits the requested operation. A denied operation can return an authorization error. Row and column restrictions can instead omit rows, mask values with null, or leave an update with zero affected rows. Inspect returned data and affected-row counts as well as HTTP errors.
Check that the selected Data Role and grant match the application’s authentication state, target object, operation, columns, and row predicate. See Database Access Control.
Console-Based Troubleshooting
Open Database > Table Editor for the same project as the application. Compare the target table and columns with the SDK request.
Inspect the relevant grant under Grants and review its SQL preview. Check the Data Role, allowed actions, column scope, and row predicate. The schema owner’s Console access can differ from the application’s access.
For an additional illustrated read-access check, see Verify Application Data Access. That procedure compares rows visible in the Console with rows returned to an application.
Do not change grants merely to suppress an error. Confirm the access the application is intended to have, then correct the configuration or request.
Key Notes
- Inspect
message,status,code,details, andhinton structured database errors. - Use
throwOnError()when HTTP database failures should follow the exception path. - Handle transport, cancellation, validation, and parsing exceptions separately from response errors.
- Verify table definitions and filters before retrying a failed write.
- Check active Data Roles, context attributes, and Data Grants for authorization failures.
- Treat Console visibility and successful client initialization as separate from application data access.