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

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.

//Options for creating the lobby
CreateLobbyOptions createLobbyOptions = new CreateLobbyOptions
{
    IsPrivate = isPrivate,
    Player = GetPlayer(),
    Data = new Dictionary<string, DataObject>
    {
        { "Map", new DataObject(DataObject.VisibilityOptions.Public, map) },
        { "relayJoinCode", new DataObject(DataObject.VisibilityOptions.Member, "0") }
    }
};
//Options for updating the lobby
Lobby lobby = await Lobbies.Instance.UpdateLobbyAsync(joinedLobby.Id, new UpdateLobbyOptions
{
    IsPrivate = true,
    IsLocked = true,
    Data = new Dictionary<string, DataObject>
    {
        {"Map", new DataObject(DataObject.VisibilityOptions.Member, joinedLobby.Data["Map"].Value) }, //BAD
        { "relayJoinCode", new DataObject(DataObject.VisibilityOptions.Member, relayCode) } //FINE
    }
});

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!

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.

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.

That worked, thanks!