Skip to content

fix(ts-sdk): resolve sqlite db paths in OSS mode#4291

Open
mudrii wants to merge 1 commit intomem0ai:mainfrom
mudrii:fix/sqlite-path-resolution
Open

fix(ts-sdk): resolve sqlite db paths in OSS mode#4291
mudrii wants to merge 1 commit intomem0ai:mainfrom
mudrii:fix/sqlite-path-resolution

Conversation

@mudrii
Copy link

@mudrii mudrii commented Mar 10, 2026

Description

Fixes two OSS SQLite path bugs in the TypeScript SDK:

  • propagate top-level historyDbPath into historyStore.config.historyDbPath when the history provider is sqlite
  • make the memory vector store SQLite path configurable via vectorStore.config.dbPath
  • default the vector store database to ~/.mem0/vector_store.db instead of resolving from process.cwd()
  • create parent directories for file-backed SQLite databases before opening them
  • add regression tests covering both fixes, including a non-writable CWD case

Fixes #4290

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (does not change functionality, e.g. code style improvements, linting)
  • Documentation update

How Has This Been Tested?

  • Unit Test
  • Test Script (please provide)

Commands run locally:

cd mem0-ts
npx prettier --check src/oss/src/config/manager.ts src/oss/src/storage/SQLiteManager.ts src/oss/src/tests/sqlite-path-resolution.test.ts src/oss/src/types/index.ts src/oss/src/utils/sqlite.ts src/oss/src/vector_stores/memory.ts
npm test -- --runInBand src/oss/src/tests/better-sqlite3-migration.test.ts src/oss/src/tests/sqlite-path-resolution.test.ts
npm run build

Additional note: npm test -- --runInBand for the entire mem0-ts package still hits pre-existing failures in unrelated integration-style tests (src/client/tests/memoryClient.test.ts, src/oss/tests/memory.test.ts) that require external services / outdated call signatures. This PR does not modify those areas.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

Maintainer Checklist

@CLAassistant
Copy link

CLAassistant commented Mar 10, 2026

CLA assistant check
All committers have signed the CLA.

Copy link

@alvinttang alvinttang left a comment

Choose a reason for hiding this comment

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

The ensureSQLiteDirectory utility is clean and the :memory: guard is correct. One subtle issue: dbPath.startsWith('file:') skips directory creation for all file-URI paths, including file:/abs/path/to/db.sqlite which is a real on-disk path — if its parent directory doesn't exist the open will fail. Consider only skipping when the path is file::memory: or contains ?mode=memory. Additionally, the top-level historyDbPath propagation in manager.ts only injects into historyStore.config when the provider is SQLite, which is correct, but if userConfig.historyStore is provided with a non-SQLite provider, the top-level historyDbPath is silently dropped — worth at minimum a warning log.

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.

[Bug] historyDbPath ignored in open-source mode — SQLite always uses relative "memory.db" + vector_store.db uses process.cwd()

3 participants