# UpdateAccountAsync throwing NullReferenceException when passing null as Username parameter

**URL:** <https://forum.heroiclabs.com/t/updateaccountasync-throwing-nullreferenceexception-when-passing-null-as-username-parameter/5207>\
**Category:** Client Libraries\
**Tags:** sdk-unity\
**Created:** [April 24, 2024, 3:01pm UTC](https://forum.heroiclabs.com/t/updateaccountasync-throwing-nullreferenceexception-when-passing-null-as-username-parameter/5207 "2024-04-24T15:01:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![UmarBhatPlaystrom](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/umarbhatplaystrom/32/1635_2.png) [@UmarBhatPlaystrom](https://forum.heroiclabs.com/u/UmarBhatPlaystrom)\
**Post date:** [April 24, 2024, 3:01pm UTC](https://forum.heroiclabs.com/t/updateaccountasync-throwing-nullreferenceexception-when-passing-null-as-username-parameter/5207/1 "2024-04-24T15:01:24Z")

</div>

According to [documentation](https://heroiclabs.com/docs/nakama/concepts/user-accounts/#update-account) you can pass a `null` as a username parameter. It also worked on Nakama-Unity SDK below version 3.6.0. We updated to 3.12.0 and now we are getting `NullReferenceException` everytime we call the method.  
As far as I understand it is supposed to take `Session.Username` if the passed username is null, as we pass the `Session` object to the method, but now it **doesn’t work as expected**.

As a workaround we now pass `Session.Username` **intentionally** :

```auto
await Client.UpdateAccountAsync(Session, Session.Username, displayName: someNickname);

```

There is no issue, it’s just that you should either return sdk behaviour to what it was before the update or just update the documentation.

Please reply if it is a desired behaviour or a bug so we could refactor code project according to new changes.

Thank you

---

<div class="post-metadata">

**Author:** ![sesposito](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/sesposito/32/2594_2.png) [@sesposito](https://forum.heroiclabs.com/u/sesposito)\
**Post date:** [April 24, 2024, 5:07pm UTC](https://forum.heroiclabs.com/t/updateaccountasync-throwing-nullreferenceexception-when-passing-null-as-username-parameter/5207/2 "2024-04-24T17:07:40Z")

</div>

Hello @UmarBhatPlaystrom,

Thank you for reporting, this will be fixed in the SDK.

As part of the changes introduced in the upgrade, the SDK now attempts to refresh the session token to update the username stored within it if a new username is passed as an argument, but a `null` argument wasn’t correctly handled.

Best.

---

<div class="post-metadata">

**Author:** ![sesposito](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/sesposito/32/2594_2.png) [@sesposito](https://forum.heroiclabs.com/u/sesposito)\
**Post date:** [April 24, 2024, 5:22pm UTC](https://forum.heroiclabs.com/t/updateaccountasync-throwing-nullreferenceexception-when-passing-null-as-username-parameter/5207/3 "2024-04-24T17:22:37Z")

</div>

PR merged: [Fix null argument for username in account update by sesposito · Pull Request #175 · heroiclabs/nakama-dotnet · GitHub](https://github.com/heroiclabs/nakama-dotnet/pull/175), expect the fix to be in the next release.
