DatabaseTool: enforce param validation and query timeouts; add tests#18
Open
Psyborgs-git wants to merge 1 commit intomainfrom
Open
DatabaseTool: enforce param validation and query timeouts; add tests#18Psyborgs-git wants to merge 1 commit intomainfrom
Psyborgs-git wants to merge 1 commit intomainfrom
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.
Motivation
paramsor omit required parameter bindings for named SQL tokens.Description
asyncio-based timeouts around SQL execution using the existing_QUERY_TIMEOUT_Sto ensure queries cannot run indefinitely (_query_readand_query_write).paramsmust be a mapping by returning an explicit error whenparamsis not adictfor read/write operations.:name) and return a clear error when SQL contains named tokens but noparamspayload is provided._PARAM_TOKEN_REand small input/validation checks and wiring to existing confirmation flow for write operations, and added a focused test moduletests/test_db_tool.pycovering the new checks and a parameterized read against an in-memory SQLite engine.Testing
python -m py_compile harness/tools/db_tool.py tests/test_db_tool.pyand no syntax errors were reported.pytest -q tests/test_db_tool.py tests/test_terminal_tool.pyin this environment but the run failed due to missing test runtime dependencypytest_asyncio(ModuleNotFoundError: No module named 'pytest_asyncio').tests/test_db_tool.pyincludes assertions for invalidparamstype handling, missing named-parameter payloads for writes, and a successful bound-parameterquery_readagainst an in-memory SQLite DB (intended to pass whenpytest_asynciois available).Codex Task