{"record":{"id":"1c0dc719aa836e73","repo":"Unity-Technologies/UnityCsReference","slug":"invalid-position-value","errorCode":null,"errorMessage":"Invalid position: {value}","messagePattern":"Invalid position: (.+?)","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/ContainerWindow.cs","lineNumber":103,"sourceCode":"\n        internal void __internalAwake()\n        {\n            hideFlags = HideFlags.DontSave;\n        }\n\n        private void OnDestroy()\n        {\n            Internal_Destroy();\n        }\n\n        // Pixel-position on screen.\n        public Rect position\n        {\n            get => Internal_Position;\n            set\n            {\n                if (!View.IsValidViewRect(value))\n                    throw new ArgumentException($\"Invalid position: {value}\");\n\n                Internal_Position = value;\n            }\n        }\n\n        internal ShowMode showMode => (ShowMode)m_ShowMode;\n\n        private string m_WindowID = null;\n        internal string windowID\n        {\n            get\n            {\n                if (String.IsNullOrEmpty(m_WindowID))\n                    return GetWindowID();\n                return m_WindowID;\n            }\n\n            set","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/ContainerWindow.cs#L85-L121","documentation":"ArgumentException thrown by the ContainerWindow.position setter when the assigned Rect fails View.IsValidViewRect. The window's pixel position/size on screen must be a valid view rectangle (finite, non-NaN, plausible dimensions); an invalid Rect is rejected before being forwarded to the native Internal_Position.","triggerScenarios":"Assigning window.position a Rect containing NaN, infinity, or negative/extreme dimensions (e.g. computed from an uninitialized layout, a deserialized corrupt window layout, or arithmetic that produced NaN).","commonSituations":"Loading a corrupt editor window layout; scripts computing window rects from monitor DPI/scale that returned NaN; restoring window position across monitors with differing resolutions.","solutions":["Validate the Rect with View.IsValidViewRect before assigning.","Sanitize computed rects (clamp sizes, reject NaN/Infinity via float.IsFinite) before use.","Discard/reset corrupt layouts instead of applying invalid rects."],"exampleFix":"// before\nwindow.position = computedRect;\n\n// after\nif (View.IsValidViewRect(computedRect))\n    window.position = computedRect;","handlingStrategy":"validation","validationCode":"if (!View.IsValidViewRect(rect)) return;\nwindow.position = rect;","typeGuard":"static bool IsValidRect(Rect r) => View.IsValidViewRect(r) && float.IsFinite(r.x) && float.IsFinite(r.y) && float.IsFinite(r.width) && float.IsFinite(r.height);","tryCatchPattern":null,"preventionTips":["Validate rects with View.IsValidViewRect before assigning.","Reject NaN/Infinity in computed layout math.","Discard corrupt layouts instead of applying them."],"tags":["unity-editor","container-window","argument-validation","rect","layout"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}