{"record":{"id":"70f094aab46e0bbc","repo":"stride3d/stride","slug":"path","errorCode":null,"errorMessage":"path","messagePattern":"path","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Navigation/NavigationComponent.cs","lineNumber":113,"sourceCode":"        /// <param name=\"path\">The resulting collection of waypoints for the found path, if any (at least 2 if a path was found)</param>\n        /// <returns>True if a valid path was found</returns>\n        public bool TryFindPath(Vector3 start, Vector3 end, IList<Vector3> path)\n        {\n            return TryFindPath(start, end, path, NavigationQuerySettings.Default);\n        }\n\n        /// <summary>\n        /// Finds a path from point <paramref cref=\"start\"/> to <paramref cref=\"end\"/>\n        /// </summary>\n        /// <param name=\"start\">The starting location of the pathfinding query</param>\n        /// <param name=\"end\">The ending location of the pathfinding query</param>\n        /// <param name=\"querySettings\">Advanced settings to be provided to the navigation mesh query</param>\n        /// <param name=\"path\">The resulting collection of waypoints for the found path, if any (at least 2 if a path was found)</param>\n        /// <returns>True if a valid path was found</returns>\n        public bool TryFindPath(Vector3 start, Vector3 end, IList<Vector3> path, NavigationQuerySettings querySettings)\n        {\n            if (path == null)\n                throw new ArgumentNullException(nameof(path));\n            if (RecastNavigationMesh == null)\n                return false;\n\n            start -= SceneOffset;\n            end -= SceneOffset;\n            if (!RecastNavigationMesh.TryFindPath(start, end, path, querySettings))\n                return false;\n            \n            for (int i = 0; i < path.Count; i++)\n            {\n                path[i] += SceneOffset;\n            }\n            return true;\n        }\n\n        /// <summary>\n        /// Performs a raycast on the navigation mesh to perform line of sight or similar checks. Starts from the entity's current world position\n        /// </summary>","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Navigation/NavigationComponent.cs#L95-L131","documentation":"NavigationComponent.TryFindPath fills the caller-supplied list with waypoints for the found path. It throws ArgumentNullException when the path list is null; a null list cannot be distinguished from 'no path found', so the library treats it as a programming error rather than returning false.","triggerScenarios":"Calling TryFindPath(start, end, null, querySettings) — e.g. declaring the output list but forgetting to instantiate it, or forwarding an uninitialized field.","commonSituations":"AI agent code requesting paths before initializing the waypoint list; passing a property that is still null on first frame; misreading the API as allocating the result list itself.","solutions":["Instantiate the list before calling: new List<Vector3>() passed as the path argument","Reuse a pre-allocated member list across path queries to avoid per-frame allocations","Note the method returns false (no throw) when the navigation mesh is null — only a null list throws; keep the list non-null and check the return value"],"exampleFix":"// before\nIList<Vector3> path = null;\nnavigationComponent.TryFindPath(start, end, path, querySettings);\n// after\nvar path = new List<Vector3>();\nif (navigationComponent.TryFindPath(start, end, path, querySettings))\n{\n    // use path\n}","handlingStrategy":"validation","validationCode":"var path = new List<Vector3>();\nif (path == null) throw new InvalidOperationException(\"path list must be initialized\");","typeGuard":"static bool HasPathList(IList<Vector3> path) => path != null;","tryCatchPattern":"try\n{\n    found = navigationComponent.TryFindPath(start, end, path, querySettings);\n}\ncatch (ArgumentNullException)\n{\n    found = false; // log: path list was null\n}","preventionTips":["Always allocate the output list before path queries","Reuse a cached member list across queries","Remember: null navmesh returns false, only a null list throws"],"tags":["csharp","null-argument","pathfinding"],"backgroundTag":"null-argument","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"}