{"record":{"id":"22584ac0cc5b7a4a","repo":"stride3d/stride","slug":"url-cannot-be-null-or-empty","errorCode":null,"errorMessage":"url cannot be null or empty.","messagePattern":"url cannot be null or empty\\.","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"sources/core/Stride.Core.Serialization/Serialization/UrlReferenceBase.cs","lineNumber":33,"sourceCode":"public abstract class UrlReferenceBase : IReference, IUrlReference\n{\n    /// <summary>\n    /// Create a new <see cref=\"UrlReferenceBase\"/> instance.\n    /// </summary>\n    protected UrlReferenceBase()\n    {\n    }\n\n    /// <summary>\n    /// Create a new <see cref=\"UrlReferenceBase\"/> instance.\n    /// </summary>\n    /// <param name=\"url\"></param>\n    /// <exception cref=\"ArgumentNullException\">If <paramref name=\"url\"/> is <c>null</c> or empty.</exception>\n    protected UrlReferenceBase(string url)\n    {\n        if (string.IsNullOrWhiteSpace(url))\n        {\n            throw new ArgumentNullException(nameof(url), $\"{nameof(url)} cannot be null or empty.\");\n        }\n\n        this.Url = url;\n    }\n\n    /// <summary>\n    /// Create a new <see cref=\"UrlReferenceBase\"/> instance.\n    /// </summary>\n    /// <exception cref=\"ArgumentNullException\">If <paramref name=\"url\"/> is <c>null</c> or empty.</exception>\n    protected UrlReferenceBase(AssetId id, string url)\n    {\n        if (string.IsNullOrWhiteSpace(url))\n        {\n            throw new ArgumentNullException(nameof(url), $\"{nameof(url)} cannot be null or empty.\");\n        }\n\n        this.Url = url;\n        this.Id = id;","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/core/Stride.Core.Serialization/Serialization/UrlReferenceBase.cs#L15-L51","documentation":"The protected UrlReferenceBase(string url) constructor requires a non-empty asset URL. Stride throws ArgumentNullException when the url parameter is null, empty, or whitespace, because a URL reference with no URL cannot point at any asset. It is a fail-fast guard for all concrete reference types (e.g. UrlReference<T>) deriving from UrlReferenceBase.","triggerScenarios":"Calling new UrlReference<T>(null), new UrlReference<T>(\"\"), or new UrlReference<T>(\"   \") — any derived class constructor invoked with a null/whitespace url string, typically from deserialization or code building references programmatically.","commonSituations":"Constructing asset references in editor tooling or build scripts where the URL string comes from an uninitialized variable, a failed file-path lookup, or a properties file that omitted the asset path.","solutions":["Pass a valid, non-empty asset URL (e.g. relative to the virtual file system, like 'myScene.sdscene') to the reference constructor.","Check the source of the string before constructing: if it comes from a config/property lookup, handle the missing value before creating the reference.","If the reference is legitimately absent, keep the field null (UrlReference is a struct and default is valid) rather than constructing with an empty URL."],"exampleFix":"// before\nvar reference = new UrlReference<Scene>(config.ScenePath); // throws if ScenePath null/empty\n// after\nif (!string.IsNullOrWhiteSpace(config.ScenePath))\n    reference = new UrlReference<Scene>(config.ScenePath);","handlingStrategy":"validation","validationCode":"if (string.IsNullOrWhiteSpace(url))\n    throw new ArgumentException(\"A non-empty asset URL is required to create a UrlReference.\", nameof(url));\nvar reference = new UrlReference<Scene>(url);","typeGuard":"static bool IsValidUrlReferenceSource(string? url) => !string.IsNullOrWhiteSpace(url);","tryCatchPattern":null,"preventionTips":["Never construct UrlReference with an empty string; leave it at default instead.","Validate config/property sources of asset paths before building references.","Centralize reference construction in a factory that validates the URL once."],"tags":["argument-validation","null-reference","assets"],"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"}