{"record":{"id":"0aa757438e8b9d71","repo":"stride3d/stride","slug":"can-not-convert-value-to-the-required-type-graphnodebase","errorCode":null,"errorMessage":"Can not convert value to the required type","messagePattern":"Can not convert value to the required type","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/presentation/Stride.Core.Quantum/GraphNodeBase.cs","lineNumber":88,"sourceCode":"        }\n\n        return null;\n    }\n\n    /// <summary>\n    /// Seal the node, indicating its construction is finished and that no more children or commands will be added.\n    /// </summary>\n    public void Seal()\n    {\n        IsSealed = true;\n    }\n\n    protected static object? ConvertValue(object? value, Type type)\n    {\n        if (value == null)\n            return null;\n        if (!TypeConverterHelper.TryConvert(value, type, out var convertedValue))\n            throw new InvalidOperationException(\"Can not convert value to the required type\");\n        return convertedValue;\n    }\n}\n","sourceCodeStart":70,"sourceCodeEnd":92,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/presentation/Stride.Core.Quantum/GraphNodeBase.cs#L70-L92","documentation":"GraphNodeBase.ConvertValue throws InvalidOperationException when TypeConverterHelper cannot convert the supplied value to the required target type. It is the safe coercion point used when setting node values, guarding against storing incompatible values in the graph.","triggerScenarios":"Assigning a value to a node or member (INode.SetData/Update) whose runtime type has no registered TypeConverter to the member's declared type, e.g. setting string \"42\" on an int member when no converter applies, or assigning incompatible object types.","commonSituations":"Data-binding values from UI (strings) into typed model members; deserializing JSON where numbers arrived as strings; type changes between library versions that removed a converter.","solutions":["Pre-convert the value yourself (Convert.ChangeType, int.Parse, etc.) before assigning","Register a custom TypeConverter in TypeConverterHelper for the source/target pair","Assign values whose runtime type matches the member's declared type","Catch InvalidOperationException on assignment and report a user-facing type error"],"exampleFix":"// before\nnode.SetData(\"42\"); // int member, no converter\n// after\nif (int.TryParse(s, out var v)) node.SetData(v);","handlingStrategy":"validation","validationCode":"if (value != null && !TypeConverterHelper.TryConvert(value, targetType, out _)) throw new InvalidOperationException($\"Cannot convert {value.GetType()} to {targetType}\");","typeGuard":"bool CanAssign<TTarget>(object? v) => v is null || v is TTarget || TypeConverterHelper.TryConvert(v, typeof(TTarget), out _);","tryCatchPattern":"try { node.Update(newValue); } catch (InvalidOperationException ex) when (ex.Message.Contains(\"convert\")) { // surface a type error to the user }","preventionTips":["Match value runtime types to member declared types","Register custom TypeConverters for domain conversions","Parse strings into typed values before assignment"],"tags":["conversion","type-mismatch","quantum"],"backgroundTag":"type-mismatch","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"}