McKael / madonctl

CLI client for the Mastodon social network API
MIT License
193 stars 9 forks source link

Unclear error message when there is an authentication error #2

Closed bortzmeyer closed 7 years ago

bortzmeyer commented 7 years ago

A typo in my email address allowed me to test the error messages:

%  madonctl config dump -i mastodon.gougere.fr  -L  nimportequoi -P encorepire
Registred new application.
Info: could not log in: login failed: ccoking for beginning of value
You can copy the following lines into a configuration file.
E.g. madonctl -i INSTANCE -L USERNAME -P PASS config dump > $HOME/.config/madonctl/madonctl.yaml

---
instance: 'https://mastodon.gougere.fr'
app_id: 'a741f6f968f405f25f9f90fe0cf789d834aa47b966a21c1cd60c86bf87bb3744'
app_secret: '3e497b0219fa94e5d573bed34445e8774ad976483eb050164b402d0fe42a5e1a'

#token: ''
#login: ''
#password: ''
safe_mode: true
...

Two problems: the second part of the error message ("cannot unmarshal server response: invalid character '<'") is useless and misleading. And no configuration file should be produced when there is not even a successful authentication.

McKael commented 7 years ago

Actually I do want to be able to dump a config file even when the user is not logged in, because I want to be able to generate the app id/secrets.

But it should fail if a username is provided and the authentication fails -- I'll do that.

Regarding the message "cannot unmarshal server response", I would say it's a serveur bug. The Mastodon server should not return an HTML error page when the authentication fails, it should return a nice JSON-encoded error message.