# Passing an api\_username for a user that does not exist returns a 500 with no useful context

**URL:** <https://meta.discourse.org/t/passing-an-api-username-for-a-user-that-does-not-exist-returns-a-500-with-no-useful-context/46407>\
**Category:** Development\
**Created:** [24 Junio, 2016 16:06 UTC](https://meta.discourse.org/t/passing-an-api-username-for-a-user-that-does-not-exist-returns-a-500-with-no-useful-context/46407 "2016-06-24T16:06:12Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)\
**Post date:** [30 Julio, 2016 19:55 UTC](https://meta.discourse.org/t/passing-an-api-username-for-a-user-that-does-not-exist-returns-a-500-with-no-useful-context/46407/5 "2016-07-30T19:55:46Z")

</div>

> [@cappslock](#):
>
> it’s raising a Discourse::InvalidAccess and the server is returning a 500.

This is actually by design as per:

> <https://github.com/discourse/discourse/blob/16a383ea1ee73e1d62da49b467a2e9fb7ea607b0/lib/auth/default_current_user_provider.rb#L68-L72>

> [@cappslock](#):
>
> enough information to determine the cause of the issue.

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.

---

_[View the full topic](https://meta.discourse.org/t/passing-an-api-username-for-a-user-that-does-not-exist-returns-a-500-with-no-useful-context/46407)._
