Repository navigation
Conversation
A wrong SQLCipher key made the connection creator raise a plain ValueError. Handlers in the server-keys route and the gRPC interceptor catch ValueError around key lookups, so that connection failure was reported to clients (404 / rejected request) instead of surfacing as an internal error. Raise DatabaseConnectionError, which is not a ValueError, so those handlers no longer leak it.
|
Thank you, the base branch and tests now follow the contribution guide. |
This branch has not been deployed
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.
Problem
When the SQLCipher key is wrong or the database file is corrupted, the connection check in
publisher/db/__init__.pyraises a plainValueError. Callers that catchValueErroraround key lookups then report this connection failure to clients:GET /v1/server-keys/{key_id}answers 404 with "Wrong key, or the database file is corrupted.", and the gRPC v3 interceptor rejects the request with the same message. Fixes #255Root cause
_make_sqlcipher3_creator'sconnect()raisesValueErroron a failedsqlite_masterintegrity check.publisher/api/rest/v1/server_keys.pyandpublisher/api/grpc/interceptors.pyboth use broadexcept ValueErroraround key lookups (for genuinely invalid key IDs), so the connection error is indistinguishable from a bad key ID and leaks to clients.Fix
Add
DatabaseConnectionError(a plainExceptionsubclass, deliberately not aValueError) inpublisher/db/__init__.pyand raise it from the SQLCipher creator instead. The two handlers keep catchingValueErrorfor real key-lookup problems; a failed connection now propagates and surfaces as a generic internal error in both the REST route and the gRPC interceptor. No handler changes needed.Testing
tests/db/test_engine.py::test_failing_sqlcipher_integrity_check_is_not_a_value_error: fails before the fix (ValueErrorraised), passes after.tests/db/test_engine.pyplus the API/db suites needsqlcipher3(Linux-only wheels) and the Rust-generated payload specs, so the full suite runs in CI.git diffis +43/-1 across two files.