llm -a - with empty stdin crashes with a traceback
A minor one. With empty stdin, llm -a - crashes with puremagic's "Input was empty" instead of the usual error.
printf '' | llm -m echo -a - hi
Tested at aebaca2, with the llm-echo plugin. I read main at b9786a2 and the code is the same.
resolve_attachment has an error for this case, "Could not determine mimetype of stdin", which it raises when mimetype_from_string returns None:
https://github.com/simonw/llm/blob/b9786a2daa44a995ff7719c655c5338bf685d551/llm/cli.py#L361-L367
mimetype_from_string only catches puremagic.PureError:
https://github.com/simonw/llm/blob/b9786a2daa44a995ff7719c655c5338bf685d551/llm/utils.py#L36-L41
For empty input puremagic raises PureValueError, which is a ValueError and not a PureError, so it gets past that and past AttachmentType.convert. mimetype_from_path has the same except, so an empty file should do the same, though I only tested stdin.
Catching (puremagic.PureError, ValueError) in both helpers would fix it. #1706 tried this and was closed by its author without merging.