openai / openai/codex-security
`snapshot_sqlite.py` hangs when source and destination are the same database
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 10.8k
- Forks
- 801
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 257
Description
Summary
sdk/typescript/_bundled_plugin/scripts/snapshot_sqlite.py can hang indefinitely when the destination refers to the same SQLite database file as the source.
The helper opens the source read-only, opens the destination separately, and then calls source_connection.backup(destination_connection). SQLite's backup API does not make progress when both connections refer to the same database file.
Reproduction
python3 - <<'PY'
import sqlite3
path = "/tmp/codex-security-snapshot-repro.sqlite3"
with sqlite3.connect(path) as connection:
connection.execute("CREATE TABLE IF NOT EXISTS t(value TEXT)")
PY
python3 sdk/typescript/_bundled_plugin/scripts/snapshot_sqlite.py \
/tmp/codex-security-snapshot-repro.sqlite3 \
/tmp/codex-security-snapshot-repro.sqlite3
The second command does not return.
Aliases to the same file can reach the same condition, so comparing path strings alone would not be sufficient.
Expected behavior
The helper should reject an existing destination that identifies the same filesystem object as the source before calling SQLite backup.
Suggested fix
Use filesystem identity (Path.samefile / os.path.samefile) when the destination already exists, fail fast with a clear diagnostic, and add a regression with a process timeout so this cannot silently become an unbounded test hang.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with sdk/typescript/_bundled_plugin/scripts/snapshot_sqlite.py and run the provided reproduction using identical source and destination paths. Check the existing-destination handling before source_connection.backup(destination_connection), including aliases to the same filesystem object. Done means the helper fails fast with a clear diagnostic and a regression test uses a process timeout to prevent an unbounded hang.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, sqlite
- Domain
- cli, databases, testing-qa
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 82/100