{"record":{"id":"e174875d0b126dd0","repo":"Unity-Technologies/UnityCsReference","slug":"scene-path-cannot-be-null-or-empty","errorCode":null,"errorMessage":"Scene path cannot be null or empty.","messagePattern":"Scene path cannot be null or empty\\.","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/Loadable/LoadableSceneIdEditorUtility.cs","lineNumber":68,"sourceCode":"                return null;\n            return AssetDatabase.LoadMainAssetAtGUID(guid) as SceneAsset;\n        }\n\n        /// <summary>\n        /// Create a LoadableSceneId object based on a scene's path.\n        /// </summary>\n        /// <param name=\"scenePath\">The scene's path within the project. Must end with .unity extension.</param>\n        /// <returns>A LoadableSceneId handle populated to reference the provided scene.</returns>\n        /// <exception cref=\"System.ArgumentNullException\">\n        /// Thrown if scenePath is null or empty.\n        /// </exception>\n        /// <exception cref=\"System.ArgumentException\">\n        /// Thrown if the path doesn't end with .unity extension or if the scene asset cannot be found at the specified path.\n        /// </exception>\n        public static LoadableSceneId CreateLoadableSceneId(string scenePath)\n        {\n            if (string.IsNullOrEmpty(scenePath))\n                throw new ArgumentNullException(nameof(scenePath), \"Scene path cannot be null or empty.\");\n            if (!scenePath.EndsWith(\".unity\", StringComparison.CurrentCultureIgnoreCase))\n                throw new ArgumentException($\"Path {scenePath} is not a scene path. Must end with .unity extension.\");\n            var guid = new GUID(AssetDatabase.AssetPathToGUID(scenePath));\n            if (guid.Empty())\n                throw new ArgumentException($\"Couldn't locate scene asset at path {scenePath}\");\n            return CreateLoadableSceneId(guid);\n        }\n    }\n}\n","sourceCodeStart":50,"sourceCodeEnd":78,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/Loadable/LoadableSceneIdEditorUtility.cs#L50-L78","documentation":"Thrown by LoadableSceneIdEditorUtility.CreateLoadableSceneId(string) when scenePath is null or empty. It is a defensive guard at the top of the factory that builds a LoadableSceneId handle from a scene asset path.","triggerScenarios":"Calling CreateLoadableSceneId with a null or empty string — e.g. a serialized field that was never assigned, a path read from a broken reference, or a config value left blank.","commonSituations":"Editor tooling or build scripts that consume a scene list from a configuration object where an entry is unset. A SceneAsset reference that resolved to a null path after the asset was moved or deleted.","solutions":["Validate the scene path is non-empty before calling, and skip or report the offending entry.","Fix the source of the path (serialized reference, config, inspector field) so it is populated.","Provide a clear error to the user identifying which scene entry is missing its path."],"exampleFix":"// before\nvar id = LoadableSceneIdEditorUtility.CreateLoadableSceneId(scenePath);\n\n// after\nif (string.IsNullOrEmpty(scenePath))\n    throw new InvalidOperationException(\"Scene reference is unassigned in build list.\");\nvar id = LoadableSceneIdEditorUtility.CreateLoadableSceneId(scenePath);","handlingStrategy":"validation","validationCode":"if (string.IsNullOrEmpty(scenePath)) throw new InvalidOperationException(\"Scene path is unassigned.\");","typeGuard":"static bool IsValidScenePath(string p) => !string.IsNullOrEmpty(p);","tryCatchPattern":"try { CreateLoadableSceneId(scenePath); }\ncatch (ArgumentNullException) { Debug.LogError(\"Scene path missing; check the source reference.\"); }","preventionTips":["Validate scene paths from config before use","Use SceneAsset references over stored strings","Report which entry is missing"],"tags":["unity","editor","scene","argument-validation","loadable-scene"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}