{"record":{"id":"9a6292f253093056","repo":"Unity-Technologies/UnityCsReference","slug":"name","errorCode":null,"errorMessage":"name","messagePattern":"name","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/AssetPipeline/AssetImporter.bindings.cs","lineNumber":47,"sourceCode":"                if (asset == null)\n                {\n                    throw new ArgumentNullException(\"asset\");\n                }\n\n                this.type = asset.GetType();\n                this.name = asset.name;\n            }\n\n            public SourceAssetIdentifier(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;\n                this.name = name;\n            }\n\n            public Type type;\n            public string name;\n        }\n\n        [NativeName(\"AssetPathName\")]\n        public extern  string assetPath\n        {","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/AssetPipeline/AssetImporter.bindings.cs#L29-L65","documentation":"AssetImporter.SourceAssetIdentifier(Type type, string name) constructor throws ArgumentNullException with param name 'name' when name is null. This is a distinct check from the empty-string check (error 36): null triggers ArgumentNullException, empty string triggers ArgumentException. The name field stores the sub-asset's name for import remapping.","triggerScenarios":"Constructing new SourceAssetIdentifier(type, null) where the name argument is null. This happens when reading a name from serialized data where the name field is absent/null, or from an asset whose .name property was never set and returned null via a custom path.","commonSituations":"Remap configuration loaded from external files (JSON/XML) where the name field is optional or omitted. Also occurs when iterating sub-assets whose names are null in edge cases (e.g., unnamed scriptable objects or assets created programmatically without a name).","solutions":["Null-check name: if (name != null) new SourceAssetIdentifier(type, name).","Coalesce null to empty string only if empty is acceptable: name = name ?? string.Empty (but note error 36 will fire if empty).","Validate serialized data has non-null, non-empty name fields before constructing identifiers."],"exampleFix":"// before\nvar id = new SourceAssetIdentifier(type, subAssetName);\n\n// after\nif (!string.IsNullOrEmpty(subAssetName))\n    var id = new SourceAssetIdentifier(type, subAssetName);\nelse\n    Debug.LogWarning($\"Skipping SourceAssetIdentifier: name is null or empty for type {type}\");","handlingStrategy":"validation","validationCode":"if (!string.IsNullOrEmpty(name))\n    var id = new AssetImporter.SourceAssetIdentifier(type, name);\nelse\n    Debug.LogWarning($\"Skipping SourceAssetIdentifier: name is null or empty\");","typeGuard":"static bool IsValidIdentifierName(string name) => !string.IsNullOrEmpty(name);","tryCatchPattern":"try { var id = new AssetImporter.SourceAssetIdentifier(type, name); }\ncatch (ArgumentNullException ex) when (ex.ParamName == \"name\")\n{ Debug.LogWarning($\"Skipped SourceAssetIdentifier: name was null\"); }","preventionTips":["Use string.IsNullOrEmpty to catch both null and empty names","Validate serialized name fields are present and non-empty before constructing","Filter blank-named sub-assets from remap lists"],"tags":["unity","csharp","asset-pipeline","asset-importer","source-asset-identifier","null-check"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}