Skip to content

Bug on Windows: async SafeOpen validation blocks all local media files for reasoning models due to stat.dev !== lstat.dev mismatch #25878

@Skrblik

Description

@Skrblik
  • In v2026.2.23, you fixed the Windows ENOENT / 404 issue in the dashboard by updating the synchronous version of the file checking logic (sameFileIdentity in src/infra/safe-open-sync.ts), which compared stat.dev and lstat.dev.
  • However, the exact same bug still exists in the asynchronous version openVerifiedLocalFile() inside src/infra/fs-safe.ts (compiled to fs-safe-DmYE85G9.js).
  • Because of this, when a user uploads an image on Windows and the agent is running a reasoning model (which passes media attachments through this validation), the image is silently dropped with the following log: Local media path is not safe to read: C:\...\media\inbound\....
  • The code in fs-safe.ts currently does this:
const [stat, lstat] = await Promise.all([handle.stat(), fs$1.lstat(filePath)]);
if (stat.ino !== lstat.ino || stat.dev !== lstat.dev) throw new SafeOpenError("path-mismatch", "path changed during read");
  • On Windows, lstat sometimes returns dev: 0, whereas stat returns the actual volume serial number, making the check fail consistently.
  • A similar check later in the function against realStat also fails.
  • The proposed fix is to apply the exact same logic as in sameFileIdentity (e.g., checking if one of the devs is 0, or bypassing the dev check on Windows entirely).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions