Skip to content

Improve error message when status database is locked (#720) - #1227

Open
chiliec wants to merge 2 commits into
pimutils:mainfrom
chiliec:improve-locked-db-error
Open

chiliec wants to merge 2 commits into
pimutils:mainfrom
chiliec:improve-locked-db-error

Conversation

@chiliec

@chiliec chiliec commented Sep 3, 2026

Copy link
Copy Markdown

Closes #720.

What

When the sqlite status database is locked (another vdirsyncer process running,
or a previous run interrupted), vdirsyncer sync printed a bare "Unknown error
occurred … Use -vdebug to see the full traceback." That's what the issue asked
to improve.

Fix

handle_cli_error now catches sqlite3.OperationalError. If the message is
database is locked, it prints an actionable hint (make sure no other
vdirsyncer process is running; delete the .items file for the collection as a
last resort). Any other OperationalError is re-raised so it still reaches the
generic handler unchanged.

Tests

Added to tests/system/cli/test_utils.py, mirroring the existing
test_handle_cli_error:

  • test_handle_cli_error_database_locked — asserts the friendly message and no
    traceback.
  • test_handle_cli_error_other_operational_error — asserts an unrelated
    OperationalError is re-raised.

Validation

$ python -m pytest tests/system/cli/test_utils.py -q
4 passed

RED→GREEN: with the source fix reverted (tests kept), both new tests fail
(assert 'status database is locked' in … fails; DID NOT RAISE OperationalError); with the fix, all pass.

ruff format --check clean on both files. Happy to adjust the wording.

@chiliec

chiliec commented Sep 3, 2026

Copy link
Copy Markdown
Author

CI note: the three builds.sr.ht checks are red for infra reasons unrelated to this change.

codecov/project and docs/readthedocs.org are green; codecov reports +0.05% coverage from the two added tests. Locally python -m pytest tests/system/cli/test_utils.py is 4 passed, and RED→GREEN holds (reverting the source fix fails both new tests). A re-run of the sr.ht jobs should clear the AUR flake.

@WhyNotHugo

Copy link
Copy Markdown
Member

Please rebase on current main

Closes pimutils#720. A locked status database surfaced as a bare traceback under the
generic error handler. Catch the sqlite3 OperationalError and print an
actionable message; re-raise any other OperationalError unchanged.
@chiliec
chiliec force-pushed the improve-locked-db-error branch from 364f541 to 4c2cef1 Compare September 4, 2026 10:04
@chiliec

chiliec commented Sep 4, 2026

Copy link
Copy Markdown
Author

Rebased on current main — CHANGELOG conflict resolved (kept both the Python 3.14 and locked-db entries), code merged clean. Ready for another look.

ruff BLE001 (blind except BaseException) was failing the sr.ht tests-pypi
check job. The tests only ever raise sqlite3.OperationalError, so catch
exactly that.
@chiliec

chiliec commented Sep 13, 2026

Copy link
Copy Markdown
Author

Rebased on current main (the branch was already on top of ceee70d, so this is a no-op rebase). Also fixed the tests-pypi failure: ruff BLE001 flagged the blind except BaseException in the two new tests — they now catch sqlite3.OperationalError explicitly, which is the only thing they raise. ruff check + ruff format --diff clean, and the three handle_cli_error tests pass locally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve error message for when status db is locked

2 participants