Skip to content

[BUG] ChatGPT import silently overwrites distinct conversations with colliding filenames #2140

Open

Description

@fernandezbaptiste

Hullo folks,

I’m doing some research for Tessl Code Review and ran it against your repo. It flagged a potential issue, and I figured it made sense to share it with you:

Bug Description

The ChatGPT importer can report two conversations successfully imported while both resolve to the same output file. The second write replaces the first conversation.

This also affects the untitled-conversation fallback added in #1790: an untitled conversation with ID abc and a different conversation titled Untitled conversation abc, created on the same day, resolve to the same destination. The full ID in the fallback does not prevent collision with an ordinary title.

Steps To Reproduce

At commit de9adb8c, pass these two conversations to ChatGPTImporter.import_data(..., "import"):

def conversation(cid, title, text):
    return {
        "id": cid,
        "title": title,
        "create_time": 1760000000,
        "mapping": {
            "root": {
                "id": "root",
                "parent": None,
                "children": [],
                "message": {
                    "author": {"role": "user"},
                    "create_time": 1760000000,
                    "content": {"content_type": "text", "parts": [text]},
                },
            }
        },
    }

conversations = [
    conversation("abc", None, "FIRST_CONVERSATION"),
    conversation("other", "Untitled conversation abc", "SECOND_CONVERSATION"),
]

The importer resolves the title, normalises it, and builds the path from only the creation date and title in chatgpt_importer.py. Both entries therefore reach write_entity with the same path.

Expected Behavior

Distinct conversations retain separate output files, or a collision is reported before overwriting. Re-importing the same conversation can still update its existing file.

Actual Behavior

The focused reproduction returned:

{
  "success": true,
  "reported_conversations": 2,
  "file_paths": [
    "import/20251009-Untitled_conversation_abc.md",
    "import/20251009-Untitled_conversation_abc.md"
  ],
  "actual_files": 1,
  "first_content_retained": false,
  "second_content_retained": true
}

Environment and validation

  • Current source commit above; macOS arm64, Python 3.12.12.
  • Executed the current importer class and its actual filename/formatting helpers in an isolated harness. Application imports/base wiring and entity model containers were replaced with test doubles; the write boundary wrote the generated Markdown to real temporary files.
  • This proves the duplicate destination and overwrite in the focused case. I have not run the full CLI, database indexing or cloud import path.
  • The production write path delegates to FileService.write_file, which uses atomic file replacement.

Additional Context

The finding came from a retrospective review of the already-merged #1790. More generally, distinct titles that collapse to the same result in clean_filename can collide too. Using the stable conversation identity when choosing destinations, and checking the final normalised paths before writing, would avoid silently losing one entry.

Full transparency: I work at Tessl, and we've spotted that using Tessl Code Review - using repository-level context and specific review lenses that improve over time through feedback. That’s how this finding surfaced.

We’re just getting started and want to offer the tool free to open-source projects. If this is useful, happy to give you access.

Bap

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions