fix(ts-sdk): resolve SQLite db paths correctly in OSS mode#4307
Merged
fix(ts-sdk): resolve SQLite db paths correctly in OSS mode#4307
Conversation
Propagate top-level historyDbPath into historyStore.config so it survives config merging, default the memory vector store to ~/.mem0/vector_store.db instead of process.cwd(), auto-create parent directories for file-backed SQLite databases, and remove dead code in the Memory constructor. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Prevent default sqlite historyDbPath from leaking into non-sqlite providers during config merging. Consolidate and expand test coverage to 19 tests: config precedence, non-sqlite isolation, migration warning, explicit dbPath, read-only CWD, and utility edge cases. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Verify that all existing usage patterns continue to work: - empty config defaults, explicit historyStore workaround, disableHistory - supabase/non-sqlite provider configs preserved - embedder, llm, vectorStore, graphStore, customPrompt pass-through - SQLiteManager with relative, absolute, and :memory: paths - MemoryVectorStore full CRUD API, dimension checks, filters - VectorStoreConfig with/without dbPath, client instance pass-through - ensureSQLiteDirectory idempotency Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
whysosaket
approved these changes
Mar 12, 2026
This was referenced Mar 13, 2026
This was referenced Mar 14, 2026
utkarsh240799
added a commit
that referenced
this pull request
Mar 14, 2026
Includes SQLite path resolution fixes from PR #4307: - Default vector_store.db location changed from process.cwd() to ~/.mem0/ - historyDbPath config propagation fix - Auto-create parent directories for SQLite DB files Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
jamebobob
pushed a commit
to jamebobob/mem0-vigil-recall
that referenced
this pull request
Mar 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes SQLite path handling bugs in OSS mode for the TypeScript SDK.
Fixes #4290
Fixes #4080
Fixes #4096
Problem
There are two SQLite path bugs in OSS mode that cause failures in daemon/service/container environments:
Bug 1:
historyDbPathis silently ignoredConfigManager.mergeConfig()always spreadsDEFAULT_MEMORY_CONFIG.historyStore(which hardcodeshistoryDbPath: "memory.db") into the merged config. Since spreadingundefinedover the default is a no-op,historyStoreis always truthy after merging. TheMemoryconstructor then always takes thehistoryStorebranch, making the top-levelhistoryDbPathdead code.Bug 2:
vector_store.dbhardcoded toprocess.cwd()MemoryVectorStoredefaults topath.join(process.cwd(), "vector_store.db"), which fails when CWD is/or not writable — common in LaunchAgent, systemd, and container environments.Solution
historyDbPathintohistoryStore.config.historyDbPathduring config merging with correct precedence: explicithistoryStore.config> top-levelhistoryDbPathshorthand > defaultmemory.dbhistoryDbPath: "memory.db"from leaking into supabase/other provider configs~/.mem0/vector_store.dbinstead ofprocess.cwd()/vector_store.dbvector_store.dbis found at the old CWD-based locationMemoryconstructor — thedefaultConfigfallback was unreachable sincehistoryStoreis always populated after config mergingdbPathtoVectorStoreConfiginterface and zod schemaType of change
How Has This Been Tested?
Commands run locally:
65 tests total — all passing (41 new + 24 existing, 0 regressions).
New tests:
sqlite-path-resolution.test.ts— 19 testsConfig merging (6):
mergeConfig({ historyDbPath })populateshistoryStore.config.historyDbPathandSQLiteManagercreates the DB at the nested pathhistoryStore.configwinshistoryStore.configworks without shorthandhistoryDbPath: "memory.db"SQLiteManager (3):
ensureSQLiteDirectorycreatesa/b/c/before openingMemoryVectorStore (5):
vectorStore.config.dbPathoverrides the defaultchmod 555CWD doesn't prevent initializationUtilities (5):
recursive: trueworksNew tests:
sqlite-backward-compat.test.ts— 22 tests:memory:, reset+re-usedbPathExisting tests:
better-sqlite3-migration.test.ts— 24 tests, all passingNo regressions.
Note:
npm test -- --runInBandfor the entiremem0-tspackage 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:
Maintainer Checklist