Commit Graph
1 Commits
Author SHA1 Message Date
James TannahillandClaude Opus 5.5 e3e51a3a33 Log puremagic "Could not identify file" at debug instead of warning (#4533)
* Log puremagic 'Could not identify file' at debug, not warning

puremagic raises PureError when no signature matches, which is the normal
result for plain text and most HTML pages. guess_stream_type() caught it
with every other exception and logged a warning on many checks, although
the content-based detection that follows handles it as designed. Other
puremagic failures still log a warning.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Skip puremagic on empty content and catch PureError directly

puremagic.magic_string() raises ValueError('Input was empty') for empty
input, which is as normal as an unidentified signature, so skip the call
then. Import puremagic before the try (it is a hard dependency) so the
except clause can name PureError instead of comparing the class name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Keep the puremagic import inside the try so a missing library falls back

ImportError is caught before puremagic.PureError, so that clause is only
evaluated once the import has succeeded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 11:58:55 +02:00