fix(storage): show human-readable error for uninitialized sqlite data…#1272
Open
TryingtobeingNikhil wants to merge 2 commits intooptuna:mainfrom
Open
fix(storage): show human-readable error for uninitialized sqlite data…#1272TryingtobeingNikhil wants to merge 2 commits intooptuna:mainfrom
TryingtobeingNikhil wants to merge 2 commits intooptuna:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What problem does this fix?
This fixes Issue #469 where launching the dashboard against an entirely empty or uninitialized SQLite database crashes the application with a confusing
SQLAlchemybackend traceback rather than providing guidance to the user.Root cause
When
RDBStorageinitializes withskip_table_creation=True, it throws an underlyingsqlite3.OperationalError: no such tableinside a generic wrapper exception because the Optuna schema does not exist yet.What the fix does
It cleanly intercepts
optuna.exceptions.StorageInternalErrorduringget_rdb_storage()initialization, specifically inspects the__cause__string for missing table warnings, and prints clear CLI instructions on how to initialize a database before exiting with code1.How I tested it
optuna-dashboard sqlite:///empty_db.sqlite3on a blank file and confirmed the new CLI instruction message appeared and exited immediately.pytestunit test simulating the empty-database crash and asserting theSystemExitcode1behavior.python_tests/suite locally to ensure no other URL inference testing logic broke.Edge cases considered
e.__cause__because the true missing table detail gets wrapped deeply inside the SDK's generic exception structure.StorageInternalErrorif it is triggered by an unrelated issue (e.g. data length violation) to avoid accidentally swallowing real bugs.