{"record":{"id":"cb2c1dfaa1de8bdd","repo":"Unity-Technologies/UnityCsReference","slug":"property-cannot-be-null","errorCode":null,"errorMessage":"Property cannot be null.","messagePattern":"Property cannot be null\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/Inspector/GraphicsSettingsInspectors/RenderPipelineGraphicsSettingsPropertyDrawer.cs","lineNumber":234,"sourceCode":"            EditorGraphicsSettings.ForEachPipelineSettings(gs => {\n                if (gs != null)\n                    s_SharedPreviousStates[gs.GetType()] = new SerializedObject(gs);\n            });\n        }\n\n        static void UpdatePreviousState(SerializedProperty property)\n            => GetPreviousState(property).Update();\n\n        static SerializedObject GetPreviousState(SerializedProperty property)\n        {\n            var type = property.serializedObject.targetObject.GetType();\n            return s_SharedPreviousStates[type];\n        }\n\n        static public void AddNotificationRequest(SerializedProperty property)\n        {\n            if (property == null)\n                throw new ArgumentException(\"Property cannot be null.\", $\"{nameof(property)}\");\n\n            //If GraphicsSettings window was open when project open, s_SharedPreviousStates can still be null when we call this.\n            if (s_SharedPreviousStates == null)\n                RecomputeDictionary();\n            \n            bool dataEquals = SerializedProperty.DataEquals(property, GetPreviousState(property).FindProperty(property.propertyPath));\n            if (dataEquals && !s_Scoped)\n                return;\n\n            NotificationRequest candidate = new(property);\n            if (dataEquals && s_NotificationRequests.Contains(candidate))\n                return;\n\n            UpdatePreviousState(property);\n            Register(candidate);\n        }\n\n        static void Register(NotificationRequest verifiedRequest)","sourceCodeStart":216,"sourceCodeEnd":252,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/Inspector/GraphicsSettingsInspectors/RenderPipelineGraphicsSettingsPropertyDrawer.cs#L216-L252","documentation":"AddNotificationRequest requires a non-null SerializedProperty to compute data-equality against the previous state and to enqueue a notification. A null property throws ArgumentException (note: it uses ArgumentException rather than ArgumentNullException, and also passes the property name as the paramName).","triggerScenarios":"Calling RenderPipelineGraphicsSettingsPropertyDrawer.AddNotificationRequest(null) or with a property that resolved to null from a FindProperty call upstream.","commonSituations":"A property path lookup (SerializedObject.FindProperty) returning null because the path doesn't exist on the graphics-settings type, then forwarding it to AddNotificationRequest. Drawer code running before the serialized object is fully initialized.","solutions":["Null-check the SerializedProperty before calling AddNotificationRequest.","Verify the property path exists on the target type (use FindProperty and check for null) before requesting a notification.","Ensure the drawer's SerializedObject is valid and initialized before invoking.","If you control the caller, short-circuit when FindProperty returns null instead of forwarding."],"exampleFix":"// before\nAddNotificationRequest(serializedObject.FindProperty(\"missingPath\")); // null -> throws\n\n// after\nvar prop = serializedObject.FindProperty(path);\nif (prop != null) AddNotificationRequest(prop);","handlingStrategy":"validation","validationCode":"var prop = serializedObject.FindProperty(path);\nif (prop == null) return; // path does not exist on this type\nRenderPipelineGraphicsSettingsPropertyDrawer.AddNotificationRequest(prop);","typeGuard":null,"tryCatchPattern":"try { AddNotificationRequest(prop); }\ncatch (ArgumentException) { /* prop null/invalid; skip notification */ }","preventionTips":["Null-check SerializedProperty results from FindProperty before forwarding.","Ensure the serialized object is initialized before requesting notifications.","Validate property paths exist on the target graphics-settings type."],"tags":["graphics-settings","property-drawer","null-argument","serialized-property","validation"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}