{"record":{"id":"b45d9e652c01192d","repo":"stride3d/stride","slug":"vector-component-w-is-invalid-only-x-and-y-are-supported","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/ControlPoints/VectorComponentControlPointViewModel.cs","lineNumber":30,"sourceCode":"        where TValue : struct\n    {\n        protected VectorComponentControlPointViewModel([NotNull] CurveViewModelBase curve, [NotNull] IMemberNode keyNode, [NotNull] IMemberNode valueNode, [NotNull] IMemberNode tangentTypeNode, VectorComponent component) \n            : base(curve, keyNode, valueNode, tangentTypeNode)\n        {\n            Component = component;\n            SynchronizePoint();\n        }\n\n        public VectorComponent Component { get; }\n    }\n\n    public sealed class Vector2ComponentControlPointViewModel : VectorComponentControlPointViewModel<Vector2>\n    {\n        public Vector2ComponentControlPointViewModel([NotNull] CurveViewModelBase curve, [NotNull] IMemberNode keyNode, [NotNull] IMemberNode valueNode, [NotNull] IMemberNode tangentTypeNode, VectorComponent component)\n            : base(curve, keyNode, valueNode, tangentTypeNode, 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        protected override double GetValue()\n        {\n            switch (Component)\n            {\n                case VectorComponent.X:\n                    return ValueBinding.Value.X;\n\n                case VectorComponent.Y:\n                    return ValueBinding.Value.Y;\n\n                case VectorComponent.Z:\n                case VectorComponent.W:\n                    throw new NotSupportedException();\n\n                default:\n                    throw new ArgumentOutOfRangeException();","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/editor/Stride.Assets.Presentation/CurveEditor/ViewModels/ControlPoints/VectorComponentControlPointViewModel.cs#L12-L48","documentation":"Raised by the Vector2ComponentControlPointViewModel constructor when the VectorComponent passed to it is W. Vector2 curves in the curve editor only expose the X and Y components, so the constructor rejects any other component value as an invalid configuration. This is a programming-error guard for curve editor view model construction.","triggerScenarios":"Constructing new Vector2ComponentControlPointViewModel(..., VectorComponent.W), usually from a shared component iteration (X, Y, Z, W) used for all vector sizes.","commonSituations":"Component loops copied from Vector4 handling; asset data that lists a W channel for what is now a Vector2 curve; copy-paste of curve descriptors across vector types.","solutions":["Pass only VectorComponent.X or VectorComponent.Y","Make the component enumeration dimension-aware (loop to 2 for Vector2)","Filter component lists derived from assets to the valid set","Catch ArgumentException and skip unsupported components"],"exampleFix":"// before\nforeach (var c in new[] { X, Y, Z, W }) CreateVector2ControlPoint(c);\n// after\nforeach (var c in new[] { VectorComponent.X, VectorComponent.Y }) CreateVector2ControlPoint(c);","handlingStrategy":"validation","validationCode":"if (!IsValidVector2Component(component)) return null;\nvar vm = new Vector2ComponentControlPointViewModel(curve, key, value, tangent, component);","typeGuard":"bool IsValidVector2Component(VectorComponent c) => c is VectorComponent.X or VectorComponent.Y;","tryCatchPattern":"try { vm = new Vector2ComponentControlPointViewModel(curve, key, value, tangent, component); }\ncatch (ArgumentException) { vm = null; }","preventionTips":["Avoid X..W loops copied from Vector4 code paths","Filter component descriptors when vector dimension changes","Add tests asserting construction succeeds only for X/Y"],"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"}