Fix connection pool resource initialization and path validation #1367

Merged
crodas merged 1 commit from feature/fix-sqlite-relative-path-bug into main 2025-12-01 21:32:46 +00:00
crodas commented 2025-12-01 17:08:01 +00:00 (Migrated from github.com)

Description

Fixes two issues in SQLite connection handling:

Connection Pool Resource Initialization:

  • Move resource creation before incrementing connection counter in pool.rs
  • Ensures counter is only incremented after successful resource creation
  • Prevents counter increment on resource creation failure
  • Fixes potential resource leak where counter could be incremented without a valid resource

Path Validation:

  • Add empty string check before parent directory existence validation
  • Allows relative paths like "test.db" to work correctly
  • Prevents false negative errors for valid relative database paths
  • Only validates parent directory existence for non-empty paths

Test Coverage:

  • Add test case bug_opening_relative_path() to verify relative path handling
  • Ensures databases can be created with simple filenames like "test.db"

These changes fix issues where:

  1. Connection pool counter could become inconsistent with actual connections
  2. Relative database paths were incorrectly rejected

Notes to the reviewers


Suggested CHANGELOG Updates

CHANGED

ADDED

REMOVED

FIXED


Checklist

### Description Fixes two issues in SQLite connection handling: **Connection Pool Resource Initialization:** - Move resource creation before incrementing connection counter in pool.rs - Ensures counter is only incremented after successful resource creation - Prevents counter increment on resource creation failure - Fixes potential resource leak where counter could be incremented without a valid resource **Path Validation:** - Add empty string check before parent directory existence validation - Allows relative paths like "test.db" to work correctly - Prevents false negative errors for valid relative database paths - Only validates parent directory existence for non-empty paths **Test Coverage:** - Add test case `bug_opening_relative_path()` to verify relative path handling - Ensures databases can be created with simple filenames like "test.db" These changes fix issues where: 1. Connection pool counter could become inconsistent with actual connections 2. Relative database paths were incorrectly rejected ----- ### Notes to the reviewers <!-- In this section you can include notes directed to the reviewers, like explaining why some parts of the PR were done in a specific way --> ----- ### Suggested [CHANGELOG](https://github.com/cashubtc/cdk/blob/main/CHANGELOG.md) Updates <!-- Please do not edit the actual changelog but note what you changed here. --> #### CHANGED #### ADDED #### REMOVED #### FIXED ---- ### Checklist * [ ] I followed the [code style guidelines](https://github.com/cashubtc/cdk/blob/main/CODE_STYLE.md) * [ ] I ran `just final-check` before committing
thesimplekid (Migrated from github.com) approved these changes 2025-12-01 21:32:27 +00:00
cdk-bot commented 2025-12-01 21:33:02 +00:00 (Migrated from github.com)

Successfully created backport PR for v0.14.x:

Successfully created backport PR for `v0.14.x`: - #1369
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cashubtc/cdk!1367
No description provided.