FiloSottile / age

A simple, modern and secure encryption tool (and Go library) with small explicit keys, no config options, and UNIX-style composability.
https://age-encryption.org
BSD 3-Clause "New" or "Revised" License
15.79k stars 477 forks source link

Unhelpful error message on invalid file #416

Open FiloSottile opened 2 years ago

FiloSottile commented 2 years ago

Discussed in https://github.com/FiloSottile/age/discussions/415

Originally posted by **shepting** May 5, 2022 I was recently using `age` in an automated fashion for some CI machines and received the following message: ``` age: error: failed to read header: parsing age header: failed to read intro: EOF ``` Unfortunately, since the error message didn't specify either: 1. the `filename` of the invalid file _or_ 2. the first line of the file it was parsing I spent 30 minutes investigating what was wrong with my private key on my machine without realizing it was the "encrypted" file that was failing to parse! My command was something like `cat ~/setup/id_rsa.encrypted | age --decrypt --identity ~/.age/ci.key --output ~/.ssh/id_rsa` so specifying that it was `STDIN` that was failing could help. Even moreso if it gave the first line of `STDIN` that didn't look right.
covert-encryption commented 1 year ago

Would make sense to give different messages for errors reading identity files and data files, e.g. prepending text on the error messages depending on which context it comes from, while keeping the original message for detailed information on what went wrong.