Skip to content

Bug: Chat atomic write path malformed — temp dir under .json/ #1049

Description

@mrveiss

Problem

Chat history atomic writes fail with malformed temp directory path:

WARNING:chat_history.session:Atomic write failed, falling back to direct write:
[Errno 2] No such file or directory: '/opt/autobot/autobot-backend/.json/.tmp_chat_l5nv9jtrdata/chats'

The path /opt/autobot/autobot-backend/.json/.tmp_chat_*data/chats is wrong — .json should not be a directory in the path. Falls back to direct write (non-atomic), risking data corruption on concurrent writes.

Discovered During

Backend log analysis during 502 debugging session.

Impact

Medium — non-atomic writes risk chat data corruption under concurrent saves. Currently masked by fallback.

Activity

  1. mrveiss commented on Feb 21, 2026

    @mrveiss
    OwnerAuthor

    Closing as duplicate of #1051, which was fixed in PR #1065 (commit e034d3d).

    Root cause: tempfile.mkstemp positional args were (dir_path, prefix, suffix) instead of (suffix, prefix, dir_path), causing the dir path to be used as suffix and ".json" as the directory — producing invalid temp paths like .json/.tmp_chat_*.

    Fix: Already merged — corrected argument order to mkstemp(".json", ".tmp_chat_", dir_path).

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