{"record":{"id":"468e484a4c353470","repo":"Unity-Technologies/UnityCsReference","slug":"fileutil-openread-failed-to-acquire-uds-content-f","errorCode":null,"errorMessage":"FileUtil.OpenRead: Failed to acquire UDS content for '{path}'","messagePattern":"FileUtil\\.OpenRead: Failed to acquire UDS content for '(.+?)'","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/FileUtil.cs","lineNumber":55,"sourceCode":"\n            // The 'physical' path for a VirtualArtifact will be a UDS virtual path\n            if (physicalPath.StartsWith(k_UdsPathPrefix, StringComparison.Ordinal))\n                return OpenReadUDS(physicalPath);\n\n            // Fall back to opening the physical file in the normal way\n            return File.Open(physicalPath, FileMode.Open, FileAccess.Read, FileShare.Read);\n        }\n\n        static Stream OpenReadUDS(string path)\n        {\n            string hashStr = path[(path.LastIndexOf('/') + 1)..];\n            var hash = Hash128.Parse(hashStr);\n            if (!hash.isValid)\n                throw new IOException($\"FileUtil.OpenRead: Invalid UDS hash in path '{path}'\");\n\n            IntPtr handle = UDS.Acquire(hash);\n            if (handle == IntPtr.Zero)\n                throw new IOException($\"FileUtil.OpenRead: Failed to acquire UDS content for '{path}'\");\n\n            return new UDSReadStream(handle);\n        }\n\n        public static byte[] ReadAllBytes(string path)\n        {\n            if (string.IsNullOrEmpty(path))\n                throw new ArgumentException(\"Path cannot be null or empty.\", nameof(path));\n\n            return ReadAllBytesInternal(path);\n        }\n\n        public static string ReadAllText(string path)\n        {\n            if (string.IsNullOrEmpty(path))\n                throw new ArgumentException(\"Path cannot be null or empty.\", nameof(path));\n\n            return ReadAllTextInternal(path);","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/FileUtil.cs#L37-L73","documentation":"After parsing the UDS hash, OpenReadUDS calls UDS.Acquire(hash); a zero IntPtr return means the native store could not resolve/lock the content for that hash, and the method throws IOException. Acquire can fail when the content was evicted from the local cache, the GUID/hash is stale, the underlying artefact was deleted, or the store is temporarily unavailable.","triggerScenarios":"Asking for UDS content by a hash that is no longer present (evicted/garbage-collected). Concurrent access where the content is being written. Corrupted local UDS cache. A hash that parsed as valid but does not correspond to stored data.","commonSituations":"Long-running editor sessions referencing UDS content that was purged. CI machines with a cold/expired cache. Tests that fabricate plausible-but-nonexistent hashes. Race between artefact deletion and a reader.","solutions":["Refresh or rebuild the UDS cache (re-import the asset) before retrying.","Catch IOException and treat as a cache miss — re-request the content from its authoritative source.","Do not hold UDS hash references across long lifetimes without verifying the content still exists.","In tests, only use hashes obtained from an actual UDS write, never synthetic ones."],"exampleFix":"// before\nusing Stream s = FileUtil.OpenRead(udsPath);\n// after\ntry { using Stream s = FileUtil.OpenRead(udsPath); /* read */ }\ncatch (IOException ex) when (ex.Message.Contains(\"acquire UDS\")) { ReimportAssetFor(udsPath); /* retry */ }","handlingStrategy":"retry","validationCode":"// Best-effort pre-check: confirm the hash resolves before opening.\nif (UDS.Acquire(hash) == IntPtr.Zero)\n    throw new IOException(\"UDS content not currently available; re-import and retry.\");","typeGuard":null,"tryCatchPattern":"try { using Stream s = FileUtil.OpenRead(udsPath); /* read */ }\ncatch (IOException ex) when (ex.Message.Contains(\"acquire UDS\"))\n{ ReimportAssetFor(udsPath); /* then retry once */ }","preventionTips":["Treat an Acquire failure as a cache miss: re-import and retry rather than aborting.","Do not retain UDS hashes across long lifetimes without re-verifying the content exists.","In tests, only use hashes produced by an actual UDS write, never synthetic ones.","Rebuild the local UDS cache when content is repeatedly unavailable."],"tags":["filesystem","uds","cache-miss","ioexception","unity-editor"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}