{"record":{"id":"197e7539e8186cc8","repo":"stride3d/stride","slug":"value-cannot-be-null-parameter-value","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'value')","messagePattern":"Value cannot be null\\. \\(Parameter 'value'\\)","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"sources/assets/Stride.Core.Assets/AssetItem.cs","lineNumber":58,"sourceCode":"    /// <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\n    /// <summary>\n    /// Gets or sets the real location of this asset if it is overriden (similar to `Link` in C# project files).\n    /// </summary>\n    public UFile? AlternativePath { get; set; }\n\n    /// <summary>\n    /// Gets the directory where the assets will be stored on the disk relative to the <see cref=\"Package\"/>. The directory\n    /// will update the list found in <see cref=\"Package.AssetFolders\"/>\n    /// </summary>\n    /// <value>The directory.</value>\n    public UDirectory? SourceFolder { get; set; }","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/assets/Stride.Core.Assets/AssetItem.cs#L40-L76","documentation":"Null-value guard reached via the location handling in the AssetItem constructor chain: a null value (typically the UFile location converted/set through the 'value' parameter) was supplied. The constructor rejects it because an AssetItem cannot have a null location.","triggerScenarios":"Assigning null to AssetItem.Location via code that does e.g. item.Location = someUnsetUFile, or a data-binding/serializer round-trip writing null into the property.","commonSituations":"Renaming/moving assets in a package session and computing the new URL from an empty string; reflection-driven property copy from a source item whose Location was null; YAML deserialization into a constructed item.","solutions":["Compute a valid non-null UFile before assigning Location (e.g. new UFile(\"/MyGame/AssetName\"))","Check that the rename/move input strings are non-empty before applying","Never assign null; remove the item and re-add instead of nulling its location","Guard assignments: only set Location when new value is non-null and non-empty"],"exampleFix":"// before\nitem.Location = newName; // newName is null/empty UFile\n// after\nif (!UFile.IsNullOrEmpty(newName))\n    item.Location = new UFile($\"/{package.Name}/{newName}\");","handlingStrategy":"validation","validationCode":"if (newLocation == null || string.IsNullOrEmpty(newLocation.FullPath))\n    throw new InvalidOperationException(\"New location must be non-empty\");\nitem.Location = newLocation;","typeGuard":"static bool ValidNewLocation(UFile v) => v != null && !string.IsNullOrWhiteSpace(v.FullPath);","tryCatchPattern":"try { item.Location = newLocation; }\ncatch (ArgumentNullException ex) when (ex.ParamName == \"value\")\n{ log.Error(\"Cannot set AssetItem.Location to null\"); }","preventionTips":["Compute new URLs from validated rename inputs","Never null out Location; recreate the item instead","Sanitize user-entered asset names before building the URL"],"tags":["assets","null-argument","property-setter"],"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"}