{"record":{"id":"72570d0a4311c019","repo":"Unity-Technologies/UnityCsReference","slug":"the-name-is-empty-72570d","errorCode":null,"errorMessage":"The name is empty","messagePattern":"The name is empty","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/AssetPipeline/SpeedTree/SpeedTreeImporterSettings.cs","lineNumber":164,"sourceCode":"            this.type = asset.GetType().ToString();\n            this.name = asset.name;\n        }\n\n        public AssetIdentifier(Type type, string name)\n        {\n            if (type == null)\n            {\n                throw new ArgumentNullException(\"type\");\n            }\n\n            if (name == null)\n            {\n                throw new ArgumentNullException(\"name\");\n            }\n\n            if (string.IsNullOrEmpty(name))\n            {\n                throw new ArgumentException(\"The name is empty\", \"name\");\n            }\n\n            this.type = type.ToString();\n            this.name = name;\n        }\n    }\n\n    /// <summary>\n    /// This attribute is used as a callback to set SRP specific properties from the importer.\n    /// </summary>\n    [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]\n    public class MaterialSettingsCallbackAttribute : Attribute\n    {\n        /// <summary>\n        /// The version of the method.\n        /// </summary>\n        public int MethodVersion;\n","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/AssetPipeline/SpeedTree/SpeedTreeImporterSettings.cs#L146-L182","documentation":"The third guard in AssetIdentifier(Type, string): once name is non-null it must also be non-empty, because an empty name is a valid C# string but a meaningless key for the importer's remapping tables (it would match nothing or collide with other empty-named entries). The library treats empty as a usage error distinct from null and throws ArgumentException so callers can tell the two mistakes apart.","triggerScenarios":"Calling new AssetIdentifier(type, \"\"); passing asset.name where the asset was created but never assigned a meaningful name; trimming user input down to empty.","commonSituations":"Imported assets with default empty names; editor tooling that lets users clear a name field; scripts that derive names from filenames and hit an edge case producing empty.","solutions":["Guarantee the name is a non-empty string before constructing; validate with !string.IsNullOrEmpty(name).","If the name comes from a path or filename, sanitize/generate a fallback name (e.g. Path.GetFileNameWithoutExtension) so it can never be empty.","Reject the offending asset upstream in the import flow with a clear message rather than constructing an invalid identifier."],"exampleFix":"// before\nvar id = new AssetIdentifier(type, asset.name);\n\n// after\nif (string.IsNullOrEmpty(asset.name))\n    throw new InvalidOperationException(\"Asset name is empty for \" + asset);\nvar id = new AssetIdentifier(type, asset.name);","handlingStrategy":"validation","validationCode":"string RequireNonEmptyName(string name) {\n    if (string.IsNullOrEmpty(name))\n        throw new InvalidOperationException(\"Asset name is empty.\");\n    return name;\n}\n// then: new AssetIdentifier(type, RequireNonEmptyName(asset.name));","typeGuard":"static bool IsValidIdentifierName(string name) => !string.IsNullOrEmpty(name);","tryCatchPattern":null,"preventionTips":["Generate names from a stable source (e.g. Path.GetFileNameWithoutExtension) so they are never empty.","Reject empty names at the UI/config layer before they reach the pipeline.","Test the empty-name and null-name cases explicitly in editor tooling."],"tags":["unity","speedtree","argument-validation","empty-string","asset-pipeline"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}