Skip to content

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 ​

SymptomWhat 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 emptyThe path in key_file / ELABFTW_KEY_FILE. ~ is expanded
404 errorsThe path in ELABFTW_HOST_URL. A bare host gets /api/v2 appended, but any other path is used as is
Team not foundIs 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's InsecureRequestWarning is not shown in that case.
  • If verify_ssl=True gives an SSLError, Python does not trust the server certificate (self-signed, internal CA, and so on). Use a proper certificate on the server, or use verify_ssl=False only 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 lock action toggles the state. 6.0.6 has no unlock action and fails with Invalid update target.. The toolkit's lock() / unlock() use forcelock / forceunlock by default (force=True), so this does not happen. With force=False, the current state is checked before sending lock.
  • Check the current state with entry.is_locked().

Permission errors (403 and others) ​

SymptomWhat to check
403 on writesWas the API key created as read-only? Do you have write permission on the entry (entry.permissions.read())?
Error when specifying organization / publicRejected by default because the access is very broad. Set ELABFTW_ALLOW_BROAD_PERMISSIONS=1 if needed
Cannot change canread_is_immutable and similareLabFTW rejects PATCH for lockdown. Use the UI
User Group not foundCheck 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 with category_title and similar.
  • A wrong field name gives KeyError for entry.fields["name"] and ValueError for fields.update(). Check the names with list(entry.fields).
  • query.first() raises ValueError when 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_index and 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 use overwrite=False.
  • files.delete_all(confirm=True) and tags.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.

Apache License 2.0