Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyValueTags are 1:n in Steamworks but 1:1 in Facepunch #731

Open
Lothsahn opened this issue Aug 14, 2023 · 1 comment
Open

KeyValueTags are 1:n in Steamworks but 1:1 in Facepunch #731

Lothsahn opened this issue Aug 14, 2023 · 1 comment
Assignees

Comments

@Lothsahn
Copy link

Describe the bug
KeyValue tags are documented (and function in steamworks) as 1:n tags:
https://partner.steamgames.com/doc/api/ISteamUGC#AddItemKeyValueTag

Multiple tags, and even duplicates of the same tag, are allowed.

In Facepunch, 1:n is allowed when writing tags. However, when reading tags off an Item, they are stored in a Dictionary of <string, string>. Duplicate values for a key collide and disappear. The current definition in UgcItem.cs is:
public Dictionary<string,string> KeyValueTags { get; internal set; }

The proper structure is:
public Dictionary<string,List> KeyValueTags { get; internal set; }

To Reproduce

  1. Create multiple values for the same key using KeyValue Tags. For instance:
    var result = await Steamworks.Ugc.Editor.NewCommunityFile
    .WithTitle($"Test")
    .AddKeyValueTag("testkey", "testvalue1")
    .AddKeyValueTag("testkey", "testvalue2")

  2. Read the values back with a UGCItem and notice that only one of the two values is read.

Calling Code

    private static async Task<Item> GetFirstItemForQuery(Query query)
    {
      List<Item> itemsForQuery = await GetItemsForQuery(query);
      if (itemsForQuery.Count > 0)
      {
        return itemsForQuery[0];
      }
      
      return new Item(0);
    }
    private static async Task<List<Item>> GetItemsForQuery(Query query)
    {
      List<Item> itemList = new();
      ResultPage? page;
      int x = 1;
      do
      {
        page = await query.GetPageAsync(x);
        x++;
        if (page.HasValue)
        {
          Debug.Log($"Got page back... {page.Value.TotalCount} item");
          foreach (var entry in page.Value.Entries)
          {
            Debug.Log($"Found item with Title:{entry.Title} and ID:{entry.Id}");
            itemList.Add(entry);
          }
        }
      } while (page.HasValue && page.Value.ResultCount > 0);

      if (itemList.Count == 0)
      {
        Debug.Log($"Did not find any results for query.");
      }

      return itemList;
    }

query = Query.All
          .WithKeyValueTags(true);
        
        Item item = await GetFirstItemForQuery(query);
        Debug.Log(item.KeyValueTags["testkey"]);

Expected behavior
I expect to see both keys in the output

Desktop (please complete the following information):

  • OS: Windows
  • Unity: 2022.3.f51

Additional context
Patch incoming.

@Lothsahn
Copy link
Author

PR available:
#732

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants