{"record":{"id":"df64578b8c956f32","repo":"Unity-Technologies/UnityCsReference","slug":"cannot-add-artifact-dependency-on-empty-guid","errorCode":null,"errorMessage":"Cannot add artifact dependency on empty GUID.","messagePattern":"Cannot add artifact dependency on empty GUID\\.","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/AssetPipeline/AssetImportContext.bindings.cs","lineNumber":165,"sourceCode":"\n        public void DependsOnArtifact(ArtifactKey key)\n        {\n            if (!key.isValid)\n            {\n                throw new ArgumentNullException(\"key\", \"Cannot add dependency on invalid ArtifactKey.\");\n            }\n\n            DependsOnArtifactInternal(key);\n        }\n\n        [NativeName(\"DependsOnArtifact\")]\n        private extern void DependsOnArtifactInternal(ArtifactKey key);\n\n        public void DependsOnArtifact(GUID guid)\n        {\n            if (guid.Empty())\n            {\n                throw new ArgumentNullException(\"guid\", \"Cannot add artifact dependency on empty GUID.\");\n            }\n\n            DependsOnArtifactInternalGUID(guid);\n        }\n\n        [NativeName(\"DependsOnArtifact\")]\n        private extern void DependsOnArtifactInternalGUID(GUID guid);\n\n        public void DependsOnArtifact(string path)\n        {\n            if (string.IsNullOrEmpty(path))\n            {\n                throw new ArgumentNullException(\"path\", \"Cannot add dependency on invalid path.\");\n            }\n\n            DependsOnArtifactInternalPath(path);\n        }\n","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/AssetPipeline/AssetImportContext.bindings.cs#L147-L183","documentation":"AssetImportContext.DependsOnArtifact(GUID guid) registers a dependency on the import artifact (compiled/processed output) of the asset identified by guid. It throws ArgumentNullException with message 'Cannot add artifact dependency on empty GUID.' when guid.Empty() is true. This is the GUID overload, distinct from the ArtifactKey overload (error 28) and the string path overload (error 30).","triggerScenarios":"Calling context.DependsOnArtifact(guid) where guid is default/uninitialized (all zeros) or was set from a failed GUID.TryParse. Common when an importer reads artifact references from serialized data that includes optional or corrupted GUID fields.","commonSituations":"ScriptedImporters that depend on the processed output of other assets (e.g., a material depending on a compiled texture's artifact). The empty GUID arises from missing cross-references, migration issues, or assets that were deleted between serialization and import.","solutions":["Check guid.Empty() before calling: if (!guid.Empty()) context.DependsOnArtifact(guid).","Validate GUIDs at parse time using GUID.TryParse and skip invalid references.","Cache resolved GUIDs and validate them against AssetDatabase.GUIDToAssetPath before declaring dependencies."],"exampleFix":"// before\ncontext.DependsOnArtifact(depGuid);\n\n// after\nif (!depGuid.Empty())\n    context.DependsOnArtifact(depGuid);\nelse\n    Debug.LogWarning($\"{context.assetPath}: empty GUID for artifact dependency, skipping\");","handlingStrategy":"validation","validationCode":"if (!guid.Empty())\n    context.DependsOnArtifact(guid);\nelse\n    Debug.LogWarning($\"{context.assetPath}: empty GUID for artifact dependency\");","typeGuard":"static bool IsValidGuid(GUID guid) => !guid.Empty();","tryCatchPattern":"try { context.DependsOnArtifact(guid); }\ncatch (ArgumentNullException ex) when (ex.ParamName == \"guid\")\n{ Debug.LogWarning($\"Skipped artifact dependency: {ex.Message}\"); }","preventionTips":["Check guid.Empty() before all GUID-based artifact dependency calls","Validate GUIDs via GUID.TryParse and GUIDToAssetPath before registering","Cache and validate resolved GUIDs to avoid stale references"],"tags":["unity","csharp","asset-pipeline","scripted-importer","dependency-graph","guid","null-check"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}