Repository navigation
fix(importers): prevent colliding filenames from overwriting conversations - #2171
aloneangel45 wants to merge 1 commit into
Conversation
|
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2c90e330c0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| candidates = [path] | ||
| if disambiguator: | ||
| candidates.append(f"{path}-{disambiguator}") |
There was a problem hiding this comment.
Keep collision paths stable across input order
When a colliding pair is re-imported after the source list order changes, this gives the first item the bare path and only suffixes the later item; the previously suffixed item then moves to the bare path while its old suffixed file remains, leaving duplicate notes with changing permalinks. Preserve the same ID-to-path mapping across batches.
AGENTS.md reference: AGENTS.md:L159-L161
Useful? React with 👍 / 👎.
|
Updated in 704e2c4 to address the review feedback and DCO sign-off:
|
2c90e33 to
704e2c4
Compare
…tions Signed-off-by: aloneangel45 <aloneangel45@users.noreply.github.com>
Summary
Prevents
ChatGPTImporterandClaudeConversationsImporterfrom silently overwriting distinct conversations when two entries resolve to the same normalized output filename within an import batch (for example an untitled conversation falling back toUntitled conversation <id>alongside an explicit title"Untitled conversation <id>", distinct punctuation collapsing underclean_filename, or case-only differences on case-insensitive filesystems).Changes
src/basic_memory/importers/base.py:Importer.resolve_unique_import_paths(path, seen_paths, disambiguator=None), tracking normalized (casefold()) target paths per import batch and appending a deterministic suffix (-<disambiguator>, falling back to-2,-3, ...) when a path collides with an earlier conversation, while keeping non-colliding filenames and re-import updates unchanged.src/basic_memory/importers/chatgpt_importer.py:_stable_id(shared between_resolve_titleandimport_data) and switchedChatGPTImporter.import_datatoresolve_unique_import_pathswithclean_filename(stable_id)[:32]asdisambiguator.src/basic_memory/importers/claude_conversations_importer.py:ClaudeConversationsImporter.import_datato useresolve_unique_import_pathswithclean_filename(uuid)[:32]asdisambiguator.tests/importers/test_conversation_filename_collisions.py:Verification
pytest --noconftest tests/importers/test_conversation_filename_collisions.py -q:3 failed(PRE_FIX_EXIT=1), confirming the second file overwrote the first.ruff checkandruff format --checkon the 4 modified/new files:0issuespytest --noconftest tests/importers/test_conversation_filename_collisions.py tests/importers/test_importer_base.py tests/importers/test_importer_utils.py tests/importers/test_import_directory_containment.py tests/importers/test_project_zip_import.py tests/importers/test_memory_json_records.py tests/importers/test_chatgpt_graphs.py -v:34 passed, 1 skipped(Windows symlink test skipped)Fixes #2140