stride3d/stride · error · ArgumentException
Vector component 'W' is invalid, only 'X' and 'Y' are…
Error message
Vector component 'W' is invalid, only 'X' and 'Y' are supported.
What it means
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.
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
Example fix
// before
foreach (var c in new[] { X, Y, Z, W }) CreateVector2ControlPoint(c);
// after
foreach (var c in new[] { VectorComponent.X, VectorComponent.Y }) CreateVector2ControlPoint(c); Defensive patterns
Strategy: validation
Validate before calling
if (!IsValidVector2Component(component)) return null; var vm = new Vector2ComponentControlPointViewModel(curve, key, value, tangent, component);
Type guard
bool IsValidVector2Component(VectorComponent c) => c is VectorComponent.X or VectorComponent.Y;
Try / catch
try { vm = new Vector2ComponentControlPointViewModel(curve, key, value, tangent, component); }
catch (ArgumentException) { vm = null; } Prevention
- 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
When it happens
Trigger: Constructing new Vector2ComponentControlPointViewModel(..., VectorComponent.W), usually from a shared component iteration (X, Y, Z, W) used for all vector sizes.
Common situations: 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.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Vector component 'W' is invalid, only 'X' and 'Y' are…
- Vector component 'Z' is invalid, only 'X' and 'Y' are…
- Vector component 'Z' is invalid, only 'X' and 'Y' are…
- Step cannot be zero or negative.
- Vector component 'W' is invalid, only 'X', 'Y' and 'Z' are…
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/b45d9e652c01192d.
Report an issue: GitHub.
Appendix: source
Thrown at sources/editor/Stride.Assets.Presentation/CurveEditor/ViewModels/ControlPoints/VectorComponentControlPointViewModel.cs:30
where TValue : struct
{
protected VectorComponentControlPointViewModel([NotNull] CurveViewModelBase curve, [NotNull] IMemberNode keyNode, [NotNull] IMemberNode valueNode, [NotNull] IMemberNode tangentTypeNode, VectorComponent component)
: base(curve, keyNode, valueNode, tangentTypeNode)
{
Component = component;
SynchronizePoint();
}
public VectorComponent Component { get; }
}
public sealed class Vector2ComponentControlPointViewModel : VectorComponentControlPointViewModel<Vector2>
{
public Vector2ComponentControlPointViewModel([NotNull] CurveViewModelBase curve, [NotNull] IMemberNode keyNode, [NotNull] IMemberNode valueNode, [NotNull] IMemberNode tangentTypeNode, VectorComponent component)
: base(curve, keyNode, valueNode, tangentTypeNode, component)
{
if (component == VectorComponent.Z) throw new ArgumentException("Vector component 'Z' is invalid, only 'X' and 'Y' are supported.", nameof(component));
if (component == VectorComponent.W) throw new ArgumentException("Vector component 'W' is invalid, only 'X' and 'Y' are supported.", nameof(component));
}
protected override double GetValue()
{
switch (Component)
{
case VectorComponent.X:
return ValueBinding.Value.X;
case VectorComponent.Y:
return ValueBinding.Value.Y;
case VectorComponent.Z:
case VectorComponent.W:
throw new NotSupportedException();
default:
throw new ArgumentOutOfRangeException();View on GitHub (pinned to 96fad776d2)