Search Unity

Resolved "Lobby validation error 1600, request failed validation" when updating lobby via updateLobbyAsync

Discussion in 'Lobby' started by BragosMagos, Mar 20, 2023.

  1. BragosMagos

    BragosMagos

    Joined:
    Oct 10, 2020
    Posts:
    2
    I've boiled it down to the "Map" parameter of the lobby data. When I remove the map parameter when updating, it works just fine, but with it in it gives me the validation error. When I create the lobby with the exact same map parameter and relaycode parameter, it works fine, but when updating it doesn't work until i remove the map parameter.

    Code (CSharp):
    1. //Options for creating the lobby
    2. CreateLobbyOptions createLobbyOptions = new CreateLobbyOptions
    3. {
    4.     IsPrivate = isPrivate,
    5.     Player = GetPlayer(),
    6.     Data = new Dictionary<string, DataObject>
    7.     {
    8.         { "Map", new DataObject(DataObject.VisibilityOptions.Public, map) },
    9.         { "relayJoinCode", new DataObject(DataObject.VisibilityOptions.Member, "0") }
    10.     }
    11. };
    Code (CSharp):
    1. //Options for updating the lobby
    2. Lobby lobby = await Lobbies.Instance.UpdateLobbyAsync(joinedLobby.Id, new UpdateLobbyOptions
    3. {
    4.     IsPrivate = true,
    5.     IsLocked = true,
    6.     Data = new Dictionary<string, DataObject>
    7.     {
    8.         {"Map", new DataObject(DataObject.VisibilityOptions.Member, joinedLobby.Data["Map"].Value) }, //BAD
    9.         { "relayJoinCode", new DataObject(DataObject.VisibilityOptions.Member, relayCode) } //FINE
    10.     }
    11. });
    Incase it matters, I'm originally getting the map string from a TMP dropdown, but I don't see why that would error at all, let alone now and not when creating the lobby. I'm really stuck here. Using Unity Editor version 2022.10 and the latest lobby version. If it matters I'm using Unity Transport 2.0.0-pre.6 for my networking. Any help would be greatly appreciated!
     
  2. bartj-unity

    bartj-unity

    Unity Technologies

    Joined:
    Sep 9, 2021
    Posts:
    26
    Based on this code, the problem will be that you are changing the visibility from public to member. If you look at the error details found in the response, you will probably see a message saying "lobby data visibility cannot be changed". The workaround would be to delete the "Map" key first and then add it again with the changed visibility.
     
  3. veleek_unity

    veleek_unity

    Ben Randall Unity Technologies

    Joined:
    Aug 25, 2021
    Posts:
    59
    When you are creating the Lobby, you are setting the visibility of "Map" to public, but when you are updating it, you are using the visibility "Member". You can't change the visibility of a property once it has been created.

    If you dig down into the exception, you should see the error message "lobby data visibility cannot be changed". If you're not seeing that error, please let us know so we can troubleshoot why.
     
  4. BragosMagos

    BragosMagos

    Joined:
    Oct 10, 2020
    Posts:
    2
    That worked, thanks!