Passing an api_username for a user that does not exist returns a 500 with no useful context

This is actually by design as per:

I believe Discourse::InvalidAccess is enough to determine that

  • either username is incorrect
  • or api_key is incorrect

If both of the above is correct than you will get specific error message.

I hope this helps.