Skip to content

feat: Enhance SQLite path validation and add related tests#61

Merged
Yashh56 merged 3 commits intoRelwave:masterfrom
Yashh56:code-improvement
Apr 9, 2026
Merged

feat: Enhance SQLite path validation and add related tests#61
Yashh56 merged 3 commits intoRelwave:masterfrom
Yashh56:code-improvement

Conversation

@Yashh56
Copy link
Copy Markdown
Member

@Yashh56 Yashh56 commented Apr 9, 2026

This pull request introduces comprehensive improvements to SQLite path handling, validation, and normalization across the codebase. The main goals are to ensure consistent storage and usage of SQLite database paths, prevent invalid configurations (such as Windows drive roots or directories), and clean up legacy, duplicated logic. The changes affect connection building, database service logic, the database store, and the SQLite connector, and are backed by expanded test coverage.

SQLite Path Normalization and Validation

  • Introduced centralized normalizeSQLitePath and isWindowsDriveRootPath utilities in bridge/src/utils/sqlitePath.ts, replacing scattered and inconsistent normalization logic throughout the codebase. ([bridge/src/utils/sqlitePath.tsR1-R40](https://github.com/Relwave/relwave-app/pull/61/files#diff-dd1fb3d6c5dfb23b4d2f20417b7b63337f5bb806b79233a243a6aa4089f6aeb5R1-R40))
  • All SQLite database paths are now normalized before being stored or used, ensuring consistent format regardless of how the path is provided (e.g., URI schemes, leading slashes). ([[1]](https://github.com/Relwave/relwave-app/pull/61/files#diff-06af935347e355c61a19972eb849674d8211cebd357d1c6bc2646870b3a84aedR199-R243), [[2]](https://github.com/Relwave/relwave-app/pull/61/files#diff-06af935347e355c61a19972eb849674d8211cebd357d1c6bc2646870b3a84aedL479-R536), [[3]](https://github.com/Relwave/relwave-app/pull/61/files#diff-06af935347e355c61a19972eb849674d8211cebd357d1c6bc2646870b3a84aedL494-R551), [[4]](https://github.com/Relwave/relwave-app/pull/61/files#diff-06af935347e355c61a19972eb849674d8211cebd357d1c6bc2646870b3a84aedL528-R589))
  • Added explicit validation to reject Windows drive roots (e.g., "D:/") and directories as invalid SQLite database paths at both connection and service layers. ([[1]](https://github.com/Relwave/relwave-app/pull/61/files#diff-85d82727f94b9a6acd6571152afd7ec10436f0613046136291986d5acfa64dc4L260-R289), [[2]](https://github.com/Relwave/relwave-app/pull/61/files#diff-8d572332fcbe9619e45eee61573eefb831d0673c8bd2deebc0dec010c549711cR19-R23))

Database Service and Store Enhancements

  • The DatabaseService now normalizes and validates SQLite paths on both add and update operations, ensuring only valid, normalized paths are persisted. ([bridge/src/services/databaseService.tsR56-R82](https://github.com/Relwave/relwave-app/pull/61/files#diff-e45d21cda98fb517adb7c6c3804f1fea48e3dbd89ab0ea67c393adb4bffb66eeR56-R82))
  • The DbStore class normalizes SQLite paths both when adding/updating entries and when loading existing configuration data, ensuring legacy or pre-existing configs are corrected automatically. ([[1]](https://github.com/Relwave/relwave-app/pull/61/files#diff-06af935347e355c61a19972eb849674d8211cebd357d1c6bc2646870b3a84aedL247-R301), [[2]](https://github.com/Relwave/relwave-app/pull/61/files#diff-06af935347e355c61a19972eb849674d8211cebd357d1c6bc2646870b3a84aedL414-R486))

Connector Improvements

  • The SQLite connector uses the new validation logic to ensure only valid, non-directory, non-drive-root paths are accepted, and provides clearer error messages when invalid paths are encountered. ([[1]](https://github.com/Relwave/relwave-app/pull/61/files#diff-85d82727f94b9a6acd6571152afd7ec10436f0613046136291986d5acfa64dc4L260-R289), [[2]](https://github.com/Relwave/relwave-app/pull/61/files#diff-85d82727f94b9a6acd6571152afd7ec10436f0613046136291986d5acfa64dc4L406-R407), [[3]](https://github.com/Relwave/relwave-app/pull/61/files#diff-85d82727f94b9a6acd6571152afd7ec10436f0613046136291986d5acfa64dc4L430-L457))

Test Coverage

  • Added and expanded tests to cover normalization and validation of SQLite paths, including edge cases such as drive roots, directories, and URI schemes, across connection building, database service, and database store layers. ([[1]](https://github.com/Relwave/relwave-app/pull/61/files#diff-493c9899f0a20a4d9e99537b89abe1610e4754bfb987de0213715b3c36182aa5R183-R189), [[2]](https://github.com/Relwave/relwave-app/pull/61/files#diff-cf0e2775e5f7b968fbda4127e6bab4b36571cacb6836f01ba1ded5ee884217e8R101-R107), [[3]](https://github.com/Relwave/relwave-app/pull/61/files#diff-bd05993a3b08063b7fae77f1da2574ec62379872a78756627eb473978c56636dR76-R104), [[4]](https://github.com/Relwave/relwave-app/pull/61/files#diff-b35a5f89a2ec20683b2a7bfedec042dcb9ca3c40bebcaf2bd61c74004fbaf6f5R103-R111), [[5]](https://github.com/Relwave/relwave-app/pull/61/files#diff-b35a5f89a2ec20683b2a7bfedec042dcb9ca3c40bebcaf2bd61c74004fbaf6f5R352-R387))

These changes collectively make SQLite handling more robust, secure, and consistent throughout the application.

@Yashh56 Yashh56 changed the title Enhance SQLite path validation and add related tests feat: Enhance SQLite path validation and add related tests Apr 9, 2026
@Yashh56 Yashh56 merged commit 398cbfe into Relwave:master Apr 9, 2026
2 checks passed
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.

1 participant