web3-unity-sdk icon indicating copy to clipboard operation
web3-unity-sdk copied to clipboard

MoralisQuery FirstOrDefaultAsync don't check if the item is null

Open Zarbuz opened this issue 1 year ago • 2 comments

In the class MoralisQuery in the FirstOrDefaultAsync method, the SDK doens't check if the item is null which causes a NullRefException.

What the function should be :

public async UniTask<T> FirstOrDefaultAsync(CancellationToken cancellationToken)
        {
            EnsureNotInstallationQuery();
            T item = await QueryService.FirstAsync<T>(this, SessionToken, cancellationToken);

            if (item != null)
            {
	            item.ObjectService = this.QueryService.ObjectService;
	            item.sessionToken = this.SessionToken;
	            return item;
            }

            return null;
        }

Zarbuz avatar Aug 01 '22 08:08 Zarbuz

Thank you for reporting this. We will look into this.

xactant avatar Aug 26 '22 12:08 xactant

Any news for a fix for this ? I am forced to maintain a local version of the SDK for my project with this fix. Not a big problem in itself but I have to think about it with each SDK update.

Zarbuz avatar Sep 28 '22 16:09 Zarbuz