# Label bug?

**URL:** <https://forum.heroiclabs.com/t/label-bug/2420>\
**Category:** Game Design\
**Created:** [March 2, 2022, 3:57pm UTC](https://forum.heroiclabs.com/t/label-bug/2420 "2022-03-02T15:57:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![atv](https://avatars.discourse-cdn.com/v4/letter/a/c67d28/32.png) [@atv](https://forum.heroiclabs.com/u/atv)\
**Post date:** [March 2, 2022, 3:57pm UTC](https://forum.heroiclabs.com/t/label-bug/2420/1 "2022-03-02T15:57:09Z")

</div>

Hi,

I have a very rare and strange bug.

Sometimes (I’d say 1 times out of 20) the values in the the match label interface will be inverted which prevent matchmaking to happen.

If my match label is like this :

```auto
interface MatchLabel {
    matchBet: number,
    playerLevel:number
    }

```

it will very rarely (1 time out of 20 or even more) be transformed like this :

```auto
interface MatchLabel {
    playerLevel:number,
    matchBet: number
   
    }

```

I can see the change in the web console.

 ![Capture d’écran 2022-03-02 à 17.02.35](https://us1.discourse-cdn.com/flex020/uploads/heroiclabs/original/2X/1/18ebf8073dca9022e485f022c84c1ebacdbfa432.png)  
 ![Capture d’écran 2022-03-02 à 17.02.42](https://us1.discourse-cdn.com/flex020/uploads/heroiclabs/original/2X/3/31719b961d37ee63eff1ca372bd4b6085a211c37.png)

It prevents a matchmaking to happen despite all the conditions met in the match label.

Any ideas what might cause this ?

---

<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:** [March 2, 2022, 4:30pm UTC](https://forum.heroiclabs.com/t/label-bug/2420/2 "2022-03-02T16:30:08Z")

</div>

A JSON encoded label doesn’t guarantee the ordering of the key/value pairs, can you please post the query you’re using to join matchmaking?

---

<div class="post-metadata">

**Author:** ![atv](https://avatars.discourse-cdn.com/v4/letter/a/c67d28/32.png) [@atv](https://forum.heroiclabs.com/u/atv)\
**Post date:** [March 2, 2022, 5:02pm UTC](https://forum.heroiclabs.com/t/label-bug/2420/3 "2022-03-02T17:02:25Z")

</div>

The function in Unity :

```auto
  public class MatchBet
    {
        public int matchBet;
        public int playerLevel;
    }

private async void FindPairImpairPvPMatch()
    {
        MatchBet playerBetToServer = new MatchBet();
        playerBetToServer.matchBet = playerRekiumsBet;
        playerBetToServer.playerLevel = playerLevel;

        
        string jsonFromClient = JsonUtility.ToJson(playerBetToServer);
        Debug.Log(jsonFromClient);
        var payload = jsonFromClient;
        var rpcid = "find_match_pairimpair";

        var serverResponse = await client.RpcAsync(session, rpcid, payload);

        var serverResponsePayload = serverResponse.Payload;

        

        MatchIDsFound serverResponseMatchId = JsonUtility.FromJson<MatchIDsFound>(serverResponsePayload);

        matchIDs = serverResponseMatchId.matchIds;

       

        //Temp Debug to see the match id
        matchIdTemp.text = serverResponseMatchId.matchIds[0];

        matchID=serverResponseMatchId.matchIds[0];

        matchVsBot = false;
        PairImpairPvPJoinMatch(); 
 }

```

On the server :

```auto
//MatchLabel is in the module representing the game.
interface MatchLabel {
    matchBet: number,
    playerLevel:number
    
}

//This function is in its own module match_rpc.ts

let rpcFindMatchPairImpair: nkruntime.RpcFunction = function (ctx: nkruntime.Context, logger: nkruntime.Logger, nk: nkruntime.Nakama, payload: string): string {
    if (!ctx.userId) {
        throw Error('No user ID in context');
    }

    if (!payload) {
        throw Error('Expects payload.');
    }

   

    let matches: nkruntime.Match[];
    try {
        
        logger.debug(ctx.userId , "Has submited the following label :", payload);
        
       

        matches = nk.matchList(10, true, payload, null, 1, null);
        
        
    } catch (error) {
        logger.error('Error listing matches: %v', error);
        throw error;
    }

    let matchIds: string[] = [];
    if (matches.length > 0) {
        // There are one or more ongoing matches the user could join.
        matchIds = matches.map(m => m.matchId);
        logger.error('Another user could join a match, we need to send him back a matchid');
        
    } else {
        // No available matches found, create a new one.
        try {
            matchIds.push(nk.matchCreate(moduleNamePairImpairPvP));
            
            
            logger.error('We have created a Pair Impair PvP match following a user request');
            
            
        } catch (error) {
            logger.error('Error creating match: %v', error);
            throw error;
        }
    }

    let res: RpcFindMatchResponse = { matchIds };
    return JSON.stringify(res);
    
}

```

---

<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:** [March 3, 2022, 11:18am UTC](https://forum.heroiclabs.com/t/label-bug/2420/4 "2022-03-03T11:18:26Z")

</div>

The `label` field of `matchList` will apply an exact match which doesn’t quite work for json encoded labels, what you want to do is use the `query` param and use the query syntax - see [Server authoritative multiplayer - Heroic Labs Documentation](https://heroiclabs.com/docs/nakama/concepts/server-authoritative-multiplayer/#search-query).
