How to remove or stabilize "rid" data?

Every time I update a StringTableCollection from Google Sheets, it changes the value of “rid” for existing entries. This frequently results in merge conflicts.

I am curious about the purpose of this “rid” and whether there is a way to either remove it or stabilize it in order to prevent merge conflicts.

The rid comes from the SerializeReference system which we use for the metadata. It is supposed to be stable though. Could you please file a bug report so we can investigate? Maybe there’s something we can do in the package to stabilize it.

2 Likes

Thank you for the prompt support. I’m trying to create an isolated test case perhaps next when if I get the time for it. I hope it’s reproducible outside of the project where it’s occurring, because I’m not in the position to share it.

Has this problem never occurred before? Perhaps it’s a problem related to the project somehow. Do you have any pointers where I could start debugging it?

I can’t say if its happened before, it’s not something I usually check for.
My theory is that the metadata is recreated when the pull occurs which results in new instances and so new rids. What metadata is it using, is it something custom or one of our own?
It could be that we just need to update the metadata and not replace it.

There is a scripting API that lets you query and control the id values https://docs.unity3d.com/ScriptReference/Serialization.ManagedReferenceUtility.html

1 Like

I was able to reproduce the issue in an isolated test project. I filed bug-report IN-66028. It would be great if the problem could be addressed relatively soon.

1 Like

The QA team was able to reproduce the issue. Thank you!

2 Likes

Hi Peter,

This is an interesting one!
We’ve got a bit of a clash between the Key Comment Column and the Max Length Column. The root of the problem is that MaxLengthMetadata inherits from Comment. So, when the Key Comment Column fetches metadata using keyEntry.Metadata.GetMetadata<Comment>(), it ends up treating MaxLengthMetadata as just another Comment.

Now, when the comment column is empty, it wipes out the comment metadata. Then, your column code kicks in, notices the missing metadata, and creates a fresh one. Each new instance requires a new RID. You may have noticed that this only happens for entries with empty comments in the Google sheet.

9603317--1361540--upload_2024-1-25_11-57-8.png

One way to fix it is by making the Key Comment Column work only with Comment and not with inherited types. But I’m not too keen on that idea because inherited types can be pretty handy.

Let’s tweak the inheritance of MaxLengthMetadata to use IMetadata instead. That means adding a new property to replace the old one. For example, we could do something like this:

 [Serializable]
 [Metadata(AllowedTypes = MetadataType.SharedStringTableEntry, AllowMultiple = false, MenuItem = "Max Length")]
 public class MaxLengthMetadata : IMetadata
 {
     [SerializeField]
     [TextArea(1, int.MaxValue)]
     string m_CommentText = "Comment Text";

     public string CommentText
     {
         get => m_CommentText;
         set => m_CommentText = value;
     }

     public int MaxLength;

     public MaxLengthMetadata()
     {
         MaxLength = 0;
     }
 }
2 Likes

Hi Karl,

thank you for looking into the issue. Great that it’s an issue with my code, so I can fix it right way. Your excellent support in this forum is greatly appreciated.

1 Like