[BUG] Text files misclassified as binary files based on file extension

Resolved 💬 2 comments Opened Jan 15, 2026 by lukas-principiot Closed Feb 27, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

I'm working in a project where I have text based configuration files with a .dat file ending (in my case configuration files for Ardupilot). These files have a mime type of text/plain, but anytime Claude Code tries to read one, the tool comes back with an error saying:

```● Read(hwdef.dat)
⎿  Error: This tool cannot read binary files. The file appears to be a binary .dat file. Please use appropriate tools for binary file analysis.

I have to ask Claude to make a copy of the file as a .txt, or use `cat` to read the file. Writing to the file requires moving it to a .txt, making the edits, then having it copy it back. 

When I run `file` on the file to check the mime type:

$file --mime-type hwdef.dat
hwdef.dat: text/plain


### What Should Happen?

Claude Code should be able to read and edit files that have a mime type of text/plain, regardless of file extension. 

### Error Messages/Logs

```shell
● Read(hwdef.dat)
  ⎿  Error: This tool cannot read binary files. The file appears to be a binary .dat file. Please use appropriate tools for binary file analysis.

$file --mime-type hwdef.dat 
hwdef.dat: text/plain

Steps to Reproduce

  1. Create a file "file.dat" with any content, i.e. echo "Hello world" > file.dat
  2. Ask Claude to read file.dat.
  3. Get the error:
❯ Read the contents of file.dat 

● Read(/tmp/bintest/file.dat)
  ⎿  Error: This tool cannot read binary files. The file appears to be a binary 
     .dat file. Please use appropriate tools for binary file analysis.

∴ Thinking…

  The file appears to be a binary file, not a text file. Let me try using bash
  to examine the file and determine what type of file it is and potentially view
   its contents in a different way.

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.7

Platform

Anthropic API

Operating System

Ubuntu/Debian Linux

Terminal/Shell

Other

Additional Information

_No response_

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗