◐ Shell
reader mode source ↗
Skip to content

fix(sqlite): raise ProgrammingError when operating on a blob with a…#6286

Merged
youknowone merged 1 commit into
RustPython:mainfrom
ever0de:sqlite/raise-programming-error-on-closed-blob
Nov 22, 2025
Merged

fix(sqlite): raise ProgrammingError when operating on a blob with a…#6286
youknowone merged 1 commit into
RustPython:mainfrom
ever0de:sqlite/raise-programming-error-on-closed-blob

Conversation

@ever0de

@ever0de ever0de commented Nov 21, 2025

Copy link
Copy Markdown
Contributor

… closed connection,

Fixed #6285

reference:

Summary by CodeRabbit

  • New Features

    • Added ability to check if a database connection is closed
  • Bug Fixes

    • Database read operations now fail gracefully with error messaging when the connection is closed

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Nov 21, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

The PR adds an is_closed() method to the Connection type and hardens Blob::read with a precondition check to raise a ProgrammingError when operating on a blob with a closed connection, aligning with CPython sqlite3 behavior.

Changes

Cohort / File(s) Summary
Blob/Connection hardening
crates/stdlib/src/sqlite.rs
Added Connection::is_closed() method to check if the underlying database is initialized and open. Enhanced Blob::read() to validate connection state before reading and raise ProgrammingError with message "Cannot operate on a closed database" if closed.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

  • Single file with localized, straightforward changes to two related methods
  • Simple conditional logic (checking Option state) with standard error handling
  • Direct correspondence to issue requirements with minimal surface area

Possibly related PRs

Suggested reviewers

  • youknowone

Poem

🐰 A rabbit's cheer for checks so keen,
When blobs on closed databases convene!
No silent fails, just errors bright,
Connection states now held so tight. ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly refers to the main change: raising ProgrammingError when operating on a blob with a closed connection, which matches the primary objective of this PR.
Linked Issues check ✅ Passed The PR addresses all coding requirements from issue #6285: adds is_closed() check to Connection, hardens Blob::read to detect closed connections, and raises ProgrammingError with the correct message.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the blob closed-connection handling issue; no unrelated modifications are present.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

📝 Customizable high-level summaries are now available in beta!

You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions:
    | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context.
    Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hide comment

Actionable comments posted: 1

📜 Review details

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f7ddcd2 and edc9f29.

⛔ Files ignored due to path filters (1)
  • Lib/test/test_sqlite3/test_dbapi.py is excluded by !Lib/**
📒 Files selected for processing (1)
  • crates/stdlib/src/sqlite.rs (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
  • GitHub Check: Check the WASM package and demo
  • GitHub Check: Run rust tests (windows-latest)
  • GitHub Check: Run tests under miri
  • GitHub Check: Run rust tests (ubuntu-latest)
  • GitHub Check: Run rust tests (macos-latest)
  • GitHub Check: Check Rust code with clippy
  • GitHub Check: Run snippets and cpython tests (windows-latest)
  • GitHub Check: Ensure compilation on various targets
  • GitHub Check: Run snippets and cpython tests (ubuntu-latest)
  • GitHub Check: Run snippets and cpython tests (macos-latest)
  • GitHub Check: Run snippets and cpython tests on wasm-wasi
  • GitHub Check: auto_format
🔇 Additional comments (1)
crates/stdlib/src/sqlite.rs (1)

1010-1012: LGTM! Clean helper method for connection state check.

The is_closed() method correctly checks the connection state by inspecting the db mutex. This provides a clear, reusable way to determine if the connection has been closed.

@youknowone youknowone left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hide comment

Thanks!

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.

sqlite: Raise ProgrammingError when operating on a blob with a closed connection

3 participants