{"record":{"id":"cc49a8144d70a9e6","repo":"stride3d/stride","slug":"value-cannot-be-null-parameter-location","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'location')","messagePattern":"Value cannot be null\\. \\(Parameter 'location'\\)","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"sources/assets/Stride.Core.Assets/AssetItem.cs","lineNumber":47,"sourceCode":"    /// <param name=\"location\">The location inside the package.</param>\n    /// <param name=\"asset\">The asset.</param>\n    /// <exception cref=\"ArgumentNullException\">location</exception>\n    /// <exception cref=\"ArgumentNullException\">asset</exception>\n    public AssetItem(UFile location, Asset asset) : this(location, asset, null)\n    {\n    }\n\n    /// <summary>\n    /// Initializes a new instance of the <see cref=\"AssetItem\" /> class.\n    /// </summary>\n    /// <param name=\"location\">The location.</param>\n    /// <param name=\"asset\">The asset.</param>\n    /// <param name=\"package\">The package.</param>\n    /// <exception cref=\"ArgumentNullException\">location</exception>\n    /// <exception cref=\"ArgumentNullException\">asset</exception>\n    internal AssetItem(UFile location, Asset asset, Package? package)\n    {\n        this.location = location ?? throw new ArgumentNullException(nameof(location));\n        this.asset = asset ?? throw new ArgumentNullException(nameof(asset));\n        Package = package;\n        isDirty = true;\n    }\n\n    /// <summary>\n    /// Gets the qualified URL of this asset (rooted under its package's namespace, e.g. /MyGame/Ground).\n    /// </summary>\n    /// <value>The location.</value>\n    [DataMember]\n    public UFile Location { get => location; internal set => location = value ?? throw new ArgumentNullException(nameof(value)); }\n\n    /// <summary>\n    /// The asset's unqualified URL: its <see cref=\"Location\"/> without the package namespace root\n    /// (equal to <see cref=\"Location\"/> for a bare package).\n    /// </summary>\n    public UFile UnqualifiedUrl => new(AssetNamespaceHelper.Unqualify(Location.FullPath, Package?.Container?.AssetNamespace ?? Package?.AssetNamespace));\n","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/assets/Stride.Core.Assets/AssetItem.cs#L29-L65","documentation":"The AssetItem constructor requires a non-null location URL; it throws ArgumentNullException with parameter name 'location'. AssetItem represents an asset at a qualified URL, so location is fundamental to its identity.","triggerScenarios":"Constructing AssetItem (directly or via Package/PackageSession APIs) passing a null UFile as location, e.g. from an unparsed path variable or a failed URL join.","commonSituations":"Building assets programmatically where the location string failed to parse into UFile (empty string yields null-ish path); migrating scripts that previously tolerated null; copying asset entries where source location was missing.","solutions":["Pass a valid, rooted UFile location string to the AssetItem constructor","Check the string you build the UFile from is non-empty before construction","If the location comes from parsing, handle parse failure before creating the AssetItem","Use UFile.IsNullOrEmpty guard prior to the call"],"exampleFix":"// before\nvar item = new AssetItem(location, asset); // location is null\n// after\nif (UFile.IsNullOrEmpty(location)) throw new InvalidOperationException(\"Asset location missing\");\nvar item = new AssetItem(location, asset);","handlingStrategy":"validation","validationCode":"if (UFile.IsNullOrEmpty(location))\n    throw new InvalidOperationException(\"Asset location required\");\nvar item = new AssetItem(location, asset, package);","typeGuard":"static bool ValidLocation(UFile loc) => !UFile.IsNullOrEmpty(loc);","tryCatchPattern":"try { item = new AssetItem(location, asset, package); }\ncatch (ArgumentNullException ex) when (ex.ParamName == \"location\")\n{ log.Error(\"Cannot create AssetItem: location is null\"); }","preventionTips":["Validate URL strings before converting to UFile","Never build locations by concatenating possibly-empty strings without checks","Fail fast on missing location at the pipeline entry point"],"tags":["assets","null-argument","asset-item"],"backgroundTag":"null-argument","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}