Repository navigation
fix: handle # character in SQLite database file paths - #718
Conversation
This fixes a critical bug where test names containing '#' characters (like "TestCacheBackends/SQLite#01") were causing database path parsing issues. The problem: When creating a SQLite database URL like `sqlite:/path/to/Test#01/db.sqlite`, Go's url.Parse() treats everything after '#' as a URL fragment. This caused database.Open() to use a different path than the migration tools, resulting in: - Migrations running on /path/to/Test#01/db.sqlite - Application opening /path/to/Test/db.sqlite (different file!) This manifested as flaky tests that failed ~50% of the time with "no such table: config" errors, because the application was literally opening an empty database file instead of the migrated one. Changes: 1. Modified openSQLite() to reconstruct the full file path by appending the URL fragment (if present) back to the path. 2. Added WAL checkpoint after migrations to ensure changes are immediately visible to new connections (defense in depth). Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Summary of ChangesHello @kalbasit, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a significant issue where SQLite database paths containing '#' characters were incorrectly parsed, causing applications to interact with an unmigrated database. The fix involves a precise reassembly of the database path to ensure consistency between migration tools and the application. Additionally, a WAL checkpoint mechanism has been implemented post-migration to guarantee immediate data visibility and robustness, particularly within test environments. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
This stack of pull requests is managed by Graphite. Learn more about stacking. |
There was a problem hiding this comment.
Code Review
This pull request addresses a critical bug in handling SQLite database file paths that contain the '#' character. The approach of reconstructing the path after url.Parse is correct in principle. However, the current implementation in pkg/database/database.go is not fully robust, as it fails to consider URLs where the path is stored in the Opaque field (e.g., sqlite:/path/to/db), which appears to be the case in your test suite. I've provided a critical comment with a code suggestion to make this logic more resilient by checking both u.Opaque and u.Path. The addition of a WAL checkpoint in the test helper is a solid defensive measure that should improve test stability.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #718 +/- ##
=======================================
Coverage 79.16% 79.16%
=======================================
Files 2 2
Lines 456 456
=======================================
Hits 361 361
Misses 83 83
Partials 12 12 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|

This fixes a critical bug where test names containing '#' characters
(like "TestCacheBackends/SQLite#01") were causing database path
parsing issues.
The problem: When creating a SQLite database URL like
sqlite:/path/to/Test#01/db.sqlite, Go's url.Parse() treatseverything after '#' as a URL fragment. This caused database.Open()
to use a different path than the migration tools, resulting in:
This manifested as flaky tests that failed ~50% of the time with
"no such table: config" errors, because the application was literally
opening an empty database file instead of the migrated one.
Changes:
appending the URL fragment (if present) back to the path.
immediately visible to new connections (defense in depth).
Co-Authored-By: Claude Sonnet 4.5 [email protected]