{"record":{"id":"6bb437932fbc5d5d","repo":"stride3d/stride","slug":"unable-to-deserialize-reference-fromscalar-value","errorCode":null,"errorMessage":"Unable to deserialize reference: [{fromScalar.Value}]","messagePattern":"Unable to deserialize reference: \\[(.+?)\\]","errorType":"exception","errorClass":"YamlException","httpStatus":null,"severity":"error","filePath":"sources/assets/Stride.Core.Assets/Serializers/IdentifiableObjectSerializer.cs","lineNumber":80,"sourceCode":"    }\n\n    private static bool TryParse(string text, out Guid identifier)\n    {\n        if (!text.StartsWith(Prefix, StringComparison.Ordinal))\n        {\n            identifier = Guid.Empty;\n            return false;\n        }\n        return Guid.TryParse(text.AsSpan(Prefix.Length), out identifier);\n    }\n\n    private class IdentifiableObjectReferenceSerializer : ScalarSerializerBase\n    {\n        public override object ConvertFrom(ref ObjectContext context, Scalar fromScalar)\n        {\n            if (!TryParse(fromScalar.Value, out var identifier))\n            {\n                throw new YamlException($\"Unable to deserialize reference: [{fromScalar.Value}]\");\n            }\n\n            // Add the path to the currently deserialized object to the list of object references\n            if (!context.SerializerContext.Properties.TryGetValue(AssetObjectSerializerBackend.ObjectReferencesKey, out var objectReferences))\n            {\n                objectReferences = new YamlAssetMetadata<Guid>();\n                context.SerializerContext.Properties.Add(AssetObjectSerializerBackend.ObjectReferencesKey, objectReferences);\n            }\n            var path = AssetObjectSerializerBackend.GetCurrentPath(ref context, true);\n            objectReferences.Set(path, identifier);\n\n            // Return default(T)\n            //return !context.Descriptor.Type.IsValueType ? null : Activator.CreateInstance(context.Descriptor.Type);\n            // Return temporary proxy instance\n            var proxy = AbstractObjectInstantiator.CreateConcreteInstance(context.Descriptor.Type);\n            // Filtering out interface and abstracts here as they're using a proxy type which doesn't have Id implemented\n            if (context.Descriptor.Type.IsInterface == false && context.Descriptor.Type.IsAbstract == false && proxy is IIdentifiable identifiable)\n                identifiable.Id = identifier;","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/assets/Stride.Core.Assets/Serializers/IdentifiableObjectSerializer.cs#L62-L98","documentation":"Thrown by IdentifiableObjectSerializer's nested IdentifiableObjectReferenceSerializer.ConvertFrom when a scalar meant to identify an object reference cannot be parsed via TryParse into an identifier. The serializer tracks object references by Guid during YAML asset deserialization; a malformed identifier stops deserialization with this YamlException.","triggerScenarios":"Deserializing a YAML asset containing an object reference scalar whose value fails IdentifiableObjectSerializer.TryParse (not a valid Guid/identifier). This happens when the reference text was hand-edited or written by an incompatible serializer version.","commonSituations":"Upgrading Stride and old assets reference objects with a changed identifier format; manual edits of object reference entries; corrupted or truncated asset files from VCS merges.","solutions":["Fix the reference scalar in the YAML to a valid identifier expected by TryParse","Re-export/resave the asset with a compatible Stride version so references are rewritten in the current format","Remove the broken reference entry and re-link the object in the editor","Compare against a known-good asset file to see the expected reference format"],"exampleFix":"// before\nReference: someObject!!\n// after\nReference: 6c9a4b1e-0f2d-4c8a-b3e5-9a1d7f02c456","handlingStrategy":"validation","validationCode":"if (Guid.TryParse(referenceText, out _)) { deserialize(); } else { report(referenceText); }","typeGuard":"bool IsParsableObjectReference(string? s) => s != null && Guid.TryParse(s, out _);","tryCatchPattern":"try { DeserializeAsset(yaml); } catch (YamlException ex) when (ex.Message.Contains(\"Unable to deserialize reference\")) { log.Warn($\"Stale object reference: {ex.Message}\"); }","preventionTips":["Re-save assets with the Stride version you deserialize with","Avoid manual edits to object reference identifiers","Check asset diffs in code review for identifier changes"],"tags":["yaml","deserialization","guid","references"],"backgroundTag":"invalid-identifier-format","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}