{"record":{"id":"754a3cb35e8509b7","repo":"stride3d/stride","slug":"vector-component-w-is-invalid-only-x-and-y-are-supported-754a3c","errorCode":null,"errorMessage":"Vector component 'W' is invalid, only 'X' and 'Y' are supported.","messagePattern":"Vector component 'W' is invalid, only 'X' and 'Y' are supported\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"sources/editor/Stride.Assets.Presentation/CurveEditor/ViewModels/VectorComponentCurveViewModel.cs","lineNumber":100,"sourceCode":"        protected abstract void UpdateComponent(ref TValue value, Vector2 realPoint);\n\n        /// <inheritdoc/>\n        protected sealed override KeyFrameControlPointViewModel<TValue> CreateKeyFrameControlPoint(IMemberNode keyNode, IMemberNode valueNode, IMemberNode tangentTypeNode)\n        {\n            return (TKeyFrameControlPointViewModel)Activator.CreateInstance(typeof(TKeyFrameControlPointViewModel), this, keyNode, valueNode, tangentTypeNode, Component);\n        }\n    }\n\n    /// <summary>\n    /// Represents the curve of one component of a <see cref=\"Vector2\"/>.\n    /// </summary>\n    public sealed class Vector2ComponentCurveViewModel : VectorComponentCurveViewModel<Vector2, Vector2ComponentControlPointViewModel>\n    {\n        public Vector2ComponentCurveViewModel([NotNull] CurveEditorViewModel editor, CurveViewModelBase parent, [NotNull] ComputeAnimationCurve<Vector2> computeCurve, VectorComponent component)\n            : base(editor, parent, computeCurve, component)\n        {\n            if (component == VectorComponent.Z) throw new ArgumentException(\"Vector component 'Z' is invalid, only 'X' and 'Y' are supported.\", nameof(component));\n            if (component == VectorComponent.W) throw new ArgumentException(\"Vector component 'W' is invalid, only 'X' and 'Y' are supported.\", nameof(component));\n        }\n\n        /// <inheritdoc/>\n        protected override void UpdateComponent(ref Vector2 value, Vector2 realPoint)\n        {\n            // Update the component that is handled by this curve\n            switch (Component)\n            {\n                case VectorComponent.X:\n                    value.X = realPoint.Y;\n                    break;\n\n                case VectorComponent.Y:\n                    value.Y = realPoint.Y;\n                    break;\n\n                default:\n                    throw new NotSupportedException(); // This should never happen","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/editor/Stride.Assets.Presentation/CurveEditor/ViewModels/VectorComponentCurveViewModel.cs#L82-L118","documentation":"Declared on Vector2ComponentCurveViewModel and its derived classes to signal that the Component assigned to a Vector2 component curve is invalid. A Vector2 only has X and Y components, so creating a curve view model bound to the W component is not supported and raises this error during curve editor initialization.","triggerScenarios":"Constructing new Vector2ComponentCurveViewModel(..., VectorComponent.W), usually from a shared component enumeration applied to all vector curve types.","commonSituations":"Component loops written for Vector4; asset channels carrying W after a type change to Vector2; copy-pasted curve descriptors.","solutions":["Pass only VectorComponent.X or VectorComponent.Y","Enumerate components according to the curve's vector dimension","Filter out W entries when curves change type","Catch ArgumentException to tolerate bad descriptors"],"exampleFix":"// before\nforeach (var c in new[] { X, Y, Z, W }) new Vector2ComponentCurveViewModel(editor, parent, curve, c);\n// after\nforeach (var c in new[] { VectorComponent.X, VectorComponent.Y }) new Vector2ComponentCurveViewModel(editor, parent, curve, c);","handlingStrategy":"validation","validationCode":"if (!IsValidVector2Component(component)) return null;\nvar curveVm = new Vector2ComponentCurveViewModel(editor, parent, curve, component);","typeGuard":"bool IsValidVector2Component(VectorComponent c) => c is VectorComponent.X or VectorComponent.Y;","tryCatchPattern":"try { vm = new Vector2ComponentCurveViewModel(editor, parent, curve, component); }\ncatch (ArgumentException) { vm = null; }","preventionTips":["Never reuse Vector4 component loops for Vector2 curves","Filter out Z/W after curve type migrations","Test component curve creation for each vector dimension"],"tags":["argument-exception","curve-editor","vector2"],"backgroundTag":"invalid-enum-value","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}