Skip to content

fix(persistence): improve error message for uninitialized SQLitePersister#613

Merged
skrawcz merged 2 commits intoapache:mainfrom
majiayu000:fix/417-sqlite-persister-error-message
Dec 31, 2025
Merged

fix(persistence): improve error message for uninitialized SQLitePersister#613
skrawcz merged 2 commits intoapache:mainfrom
majiayu000:fix/417-sqlite-persister-error-message

Conversation

@majiayu000
Copy link
Contributor

Summary

  • Improved error messages when SQLitePersister methods are called without initialization
  • Catches sqlite3.OperationalError for missing table and raises clear RuntimeError

Changes

  • Added error handling in SQLitePersister.load(), save(), and list_app_ids()
  • Error message now clearly states: "Uninitialized persister: table 'X' does not exist. Make sure to call .initialize() on the persister before passing it to the ApplicationBuilder."

Test plan

  • Added 3 new unit tests for load, save, and list_app_ids without initialize
  • All existing persistence tests pass (32 tests)
  • Pre-commit checks pass

Closes #417

…ster

When load(), save(), or list_app_ids() are called before initialize(),
raise a clear RuntimeError with actionable guidance instead of cryptic
sqlite3.OperationalError about missing table.

Closes apache#417

Signed-off-by: majiayu000 <1835304752@qq.com>
Copy link
Contributor

@skrawcz skrawcz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good -- just a small request.

Comment on lines 457 to 459
f"Uninitialized persister: table '{self.table_name}' does not exist. "
f"Make sure to call .initialize() on the persister before passing it "
f"to the ApplicationBuilder."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you make this string a constant and use it in the other places please?

Address review feedback: extract the uninitialized persister
error message to a module-level constant _UNINITIALIZED_PERSISTER_ERROR
and use it in all three places (list_app_ids, load, save).
Copy link
Contributor

@skrawcz skrawcz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@skrawcz skrawcz merged commit 692789e into apache:main Dec 31, 2025
10 of 11 checks passed
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.

fix: Improve error message for SQLitePersister

2 participants