feat(siteruntime): normalize old-form List static overrides to native JSON on load

This commit is contained in:
Joseph Doherty
2026-06-16 17:49:21 -04:00
parent bf80ca1388
commit 5841cec958
2 changed files with 176 additions and 0 deletions
@@ -948,10 +948,31 @@ public class InstanceActor : ReceiveActor
if (_resolvedAttributeByName.TryGetValue(kvp.Key, out var resolved)
&& IsListAttribute(resolved))
{
// NJ-4: decode the stored List override (both old array-of-strings
// and native-typed forms decode) and re-persist the native form if
// the stored value is still in the OLD form. Re-encoding the decoded
// list and comparing to the stored string detects old-form values
// (native → native is byte-identical, so a native value is a no-op).
// The re-persist is fire-and-forget and never throws into the actor.
var decoded = DecodeAttributeValue(resolved, kvp.Value);
_attributes[kvp.Key] = decoded;
if (decoded is null && !string.IsNullOrEmpty(kvp.Value))
{
_attributeQualities[kvp.Key] = "Bad";
}
else if (decoded is not null)
{
var native = AttributeValueCodec.Encode(decoded);
if (native != kvp.Value) // stored value was old-form → normalize on disk
{
var key = kvp.Key;
_storage.SetStaticOverrideAsync(_instanceUniqueName, key, native!)
.ContinueWith(t => _logger.LogWarning(t.Exception?.GetBaseException(),
"Failed to normalize static override {Instance}.{Attr} to native JSON",
_instanceUniqueName, key),
TaskContinuationOptions.OnlyOnFaulted);
}
}
}
else
{