Skip to content

[Bug]: Console error when clicking a binary file not in the hardcoded extension list #30

@matiaspalmac

Description

@matiaspalmac

Describe the bug

Clicking a binary file in the explorer whose extension isn't in the hardcoded bin list produces a noisy console error even though the code already handles the case gracefully (it shows the "binary file" placeholder in the editor).

In apps/desktop/src/addons/builtin.git-explorer/GitExplorerComponent.tsx the file click handler calls invoke("read_file", ...) without { silent: true }. When Rust returns stream did not contain valid UTF-8, safeInvoke logs it via console.error before re-throwing. The caller then catches the error and opens the file with the editor.bin_file placeholder, so the user flow is fine — but the error is already in the console.

[Tauri Invoke Error] read_file: "stream did not contain valid UTF-8"
src/api/tauri.ts (94:17) @ safeInvoke
  ...
async handleEntryClick
src/addons/builtin.git-explorer/GitExplorerComponent.tsx (262:23)

The hardcoded bin list only covers .png/.jpg/.jpeg/.gif/.exe/.dll/.bin/.zip/.pdf/.ico/.woff/.woff2/.ttf — many binary extensions (.webp, .mp3, .mp4, .class, .jar, .db, .sqlite, .wasm, ...) fall through to read_file, each producing this false-positive error.

As a side issue, the current catch only handles the UTF-8 case; any other read failure (permission denied, file locked, etc.) is silently swallowed — the click does nothing and the user gets no feedback.

Steps to Reproduce

  1. pnpm desktop.
  2. Open a folder containing a binary file whose extension isn't in the hardcoded bin list (e.g. .webp, .mp3, .sqlite).
  3. Click the file in the explorer.
  4. Open DevTools Console → see [Tauri Invoke Error] read_file: "stream did not contain valid UTF-8".

Trixty Version

v1.0.8 (main @ 50923f8)

OS

Windows

Fix yourself?

Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions