{"record":{"id":"735c673198b4bd01","repo":"EllanJiang/GameFramework","slug":"access-read-is-invalid","errorCode":null,"errorMessage":"Access read is invalid.","messagePattern":"Access read is invalid\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/FileSystem/FileSystemManager.cs","lineNumber":156,"sourceCode":"        {\n            if (m_FileSystemHelper == null)\n            {\n                throw new GameFrameworkException(\"File system helper is invalid.\");\n            }\n\n            if (string.IsNullOrEmpty(fullPath))\n            {\n                throw new GameFrameworkException(\"Full path is invalid.\");\n            }\n\n            if (access == FileSystemAccess.Unspecified)\n            {\n                throw new GameFrameworkException(\"Access is invalid.\");\n            }\n\n            if (access == FileSystemAccess.Read)\n            {\n                throw new GameFrameworkException(\"Access read is invalid.\");\n            }\n\n            fullPath = Utility.Path.GetRegularPath(fullPath);\n            if (m_FileSystems.ContainsKey(fullPath))\n            {\n                throw new GameFrameworkException(Utility.Text.Format(\"File system '{0}' is already exist.\", fullPath));\n            }\n\n            FileSystemStream fileSystemStream = m_FileSystemHelper.CreateFileSystemStream(fullPath, access, true);\n            if (fileSystemStream == null)\n            {\n                throw new GameFrameworkException(Utility.Text.Format(\"Create file system stream for '{0}' failure.\", fullPath));\n            }\n\n            FileSystem fileSystem = FileSystem.Create(fullPath, access, fileSystemStream, maxFileCount, maxBlockCount);\n            if (fileSystem == null)\n            {\n                throw new GameFrameworkException(Utility.Text.Format(\"Create file system '{0}' failure.\", fullPath));","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/FileSystem/FileSystemManager.cs#L138-L174","documentation":"Validation in FileSystemManager.CreateFileSystem: thrown when access is FileSystemAccess.Read, because a newly created file system is being written to and read-only access is contradictory at creation time. Use Read only when opening an existing file system; create with Write (or ReadWrite as supported).","triggerScenarios":"Calling FileSystemManager.CreateFileSystem(fullPath, FileSystemAccess.Read, maxFileCount, maxBlockCount).","commonSituations":"Confusing Open (which accepts Read) with Create (which does not); reusing a Read access variable intended for opening existing file systems; generic open-or-create wrapper passing the caller's access straight through.","solutions":["Use FileSystemAccess.ReadWrite (or Write) with CreateFileSystem; reserve Read for opening existing file systems.","Restructure open-or-create logic: try Open with Read first, then Create with ReadWrite only if it does not exist.","Map the access argument in wrapper code: force Read to ReadWrite (or reject) on the create path."],"exampleFix":"// before\nvar fs = fileSystemManager.CreateFileSystem(fullPath, FileSystemAccess.Read, 16, 1024); // throws\n// after\nvar fs = fileSystemManager.CreateFileSystem(fullPath, FileSystemAccess.ReadWrite, 16, 1024);","handlingStrategy":"validation","validationCode":"if (access == FileSystemAccess.Read)\n    access = FileSystemAccess.ReadWrite; // creation requires write capability\nif (access == FileSystemAccess.Unspecified)\n    access = FileSystemAccess.ReadWrite;","typeGuard":"static bool IsCreatableAccess(FileSystemAccess access) => access == FileSystemAccess.Write || access == FileSystemAccess.ReadWrite;","tryCatchPattern":"try { fileSystemManager.CreateFileSystem(fullPath, access, maxFileCount, maxBlockCount); }\ncatch (GameFrameworkException ex) when (ex.Message == \"Access read is invalid.\") { /* retry with ReadWrite or route to Open instead */ }","preventionTips":["Remember: Read is only valid when opening existing file systems, never when creating.","In open-or-create wrappers, normalize the access mode on the create branch.","Document and enforce with a helper method the rule 'Create => Write/ReadWrite only'."],"tags":["filesystem","access-mode","validation","creation"],"backgroundTag":"invalid-enum-value","analyzedSha":"d0c010b05167c58e92350449d04864a91ca13fd2","analyzedAt":"2026-09-15T13:37:15.352Z","contentChangedAt":"2026-09-15T13:37:15.352Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}