12. Troubleshooting
What to check when something does not work.
Turn on detailed logs first
Details of API errors are logged (logger elabftw_toolkit, DEBUG). Nothing is printed before an exception is raised.
python
import logging
logging.basicConfig(level=logging.INFO)
logging.getLogger("elabftw_toolkit").setLevel(logging.DEBUG)Many functions print diagnostic information when given debug=True.
Cannot connect / key not found
| Symptom | What to check |
|---|---|
No api_key / key_file given… | Is ELABFTW_API_KEY or ELABFTW_KEY_FILE set? If you use .env, did you call load_dotenv() (it is not loaded automatically)? |
API key file not found / API key file is empty | The path in key_file / ELABFTW_KEY_FILE. ~ is expanded |
| 404 errors | The path in ELABFTW_HOST_URL. A bare host gets /api/v2 appended, but any other path is used as is |
| Team not found | Is the name in client("team name") exactly as shown in eLabFTW? Check with elab.teams.list() |
With client(..., check=True), the connection and team are checked when the client is created.
SSL errors
- The default is
verify_ssl=False(certificates are not verified). urllib3'sInsecureRequestWarningis not shown in that case. - If
verify_ssl=Truegives anSSLError, Python does not trust the server certificate (self-signed, internal CA, and so on). Use a proper certificate on the server, or useverify_ssl=Falseonly on test servers.
429 (too many requests) / 5xx (server errors)
- GET requests made directly by the toolkit (
elab.get(),raw(),all(), and so on) are retried up to 4 times with pauses of 2, 4, and 8 seconds on connection errors, timeouts, 429, and 500/502/503/504. The timeout is 60 seconds. - PATCH / POST (writes) and calls through the SDK (elabapi-python) are not retried. If a bulk-writing script stops, make it safe to re-run as in 11. Recipes and run it again.
- When writing a lot, adding something like
time.sleep(0.5)in the loop reduces the load on the server.
Locking (eLabFTW 6.0.x)
- Trying to change a locked entry may fail. Wrap the code in
with entry.unlocked():. - In eLabFTW 6.x the
lockaction toggles the state. 6.0.6 has nounlockaction and fails withInvalid update target.. The toolkit'slock()/unlock()useforcelock/forceunlockby default (force=True), so this does not happen. Withforce=False, the current state is checked before sendinglock. - Check the current state with
entry.is_locked().
Permission errors (403 and others)
| Symptom | What to check |
|---|---|
| 403 on writes | Was the API key created as read-only? Do you have write permission on the entry (entry.permissions.read())? |
Error when specifying organization / public | Rejected by default because the access is very broad. Set ELABFTW_ALLOW_BROAD_PERMISSIONS=1 if needed |
Cannot change canread_is_immutable and similar | eLabFTW rejects PATCH for lockdown. Use the UI |
| User Group not found | Check the names with entry.permissions.usergroups(debug=True) |
Not found / found more than once
find(),set_item_field(item_title=...), and similar use exact title matches. Watch for full-width/half-width characters and spaces. Narrow multiple hits withcategory_titleand similar.- A wrong field name gives
KeyErrorforentry.fields["name"]andValueErrorforfields.update(). Check the names withlist(entry.fields). query.first()raisesValueErrorwhen nothing matches.
Other
- Garbled Japanese in PDFs: enable a CJK font in eLabFTW under "Settings > General > PDF settings".
- HTML tables shift: check whether the order of tables in the template changed, and fix
table_indexand the other indexes (9. HTML tables).
Safety notes (summary)
- The API key is a secret. Handle
.env,tests/live/.env.test, logs, and shared zip files with care. metadata.update(..., overwrite=True)replaces the whole metadata. Normally useoverwrite=False.files.delete_all(confirm=True)andtags.clear(confirm=True)delete in bulk.- Try permission changes and the test scripts on a test team, templates, and entries before using them in production.