Documentation Index
Fetch the complete documentation index at: https://docs.larksh.com/llms.txt
Use this file to discover all available pages before exploring further.
Error handling
The Lark SDK uses a consistent error model. Every error thrown by the SDK is aLarkError instance with a machine-readable code and a human-readable message.
Error structure
Error codes
| Code | Description |
|---|---|
permission_denied | Security rules rejected the operation. The authenticated user (or anonymous client) doesn’t have access to the requested path or operation. |
invalid_data | The data you tried to write is malformed. This includes invalid key characters, values that exceed size limits, or structurally invalid data. |
not_found | The requested path doesn’t exist. Returned by certain operations that expect existing data. |
invalid_path | The path string is malformed. Paths can’t contain ., #, $, [, or ] characters. |
timeout | The operation didn’t complete within the timeout window (30 seconds by default). |
not_connected | You attempted an operation that requires a connection while the client is disconnected. |
condition_failed | A transaction’s condition check failed. The data didn’t match the expected state. |
max_retries_exceeded | A transaction was retried 25 times and still couldn’t commit due to contention. |
write_tainted | A write was rejected because it depended on a prior write that failed. This prevents cascading inconsistencies. |
auth_required | The operation requires authentication, but the client is connected anonymously and security rules demand an authenticated user. |
Handling write errors
All write operations (set, update, remove, push) return promises. Wrap them in try/catch:
Handling read errors
Read operations (once, get) can also fail:
Handling transaction errors
Transactions can fail for additional reasons beyond normal write errors:Connection-level errors
For errors that aren’t tied to a specific operation (transport failures, authentication errors, protocol issues), usedb.onError():
db.onError() returns an unsubscribe function, just like other event listeners. Clean it up when you no longer need it.Best practices
- Wrap writes in try/catch. Even if you’re confident your security rules will allow the write, network issues or data validation can cause failures.
- Log errors with their codes. The
codefield is stable and machine-readable. Use it for programmatic decisions. Usemessagefor human-readable logging. - Use
db.onError()as a safety net. It catches connection-level issues that individual operation error handling might miss. - Don’t swallow errors silently. At minimum, log them. Silently dropped errors make debugging much harder.

