{"record":{"id":"5bb683ee80e81254","repo":"EllanJiang/GameFramework","slug":"access-is-invalid","errorCode":null,"errorMessage":"Access is invalid.","messagePattern":"Access is invalid\\.","errorType":"validation","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/FileSystem/FileSystem.cs","lineNumber":60,"sourceCode":"        private int m_StringDataOffset;\n        private int m_FileDataOffset;\n\n        /// <summary>\n        /// 初始化文件系统的新实例。\n        /// </summary>\n        /// <param name=\"fullPath\">文件系统完整路径。</param>\n        /// <param name=\"access\">文件系统访问方式。</param>\n        /// <param name=\"stream\">文件系统流。</param>\n        private FileSystem(string fullPath, FileSystemAccess access, FileSystemStream stream)\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 (stream == null)\n            {\n                throw new GameFrameworkException(\"Stream is invalid.\");\n            }\n\n            m_FullPath = fullPath;\n            m_Access = access;\n            m_Stream = stream;\n            m_FileDatas = new Dictionary<string, int>(StringComparer.Ordinal);\n            m_BlockDatas = new List<BlockData>();\n            m_FreeBlockIndexes = new GameFrameworkMultiDictionary<int, int>();\n            m_StringDatas = new SortedDictionary<int, StringData>();\n            m_FreeStringIndexes = new Queue<int>();\n            m_FreeStringDatas = new Queue<StringData>();\n\n            m_HeaderData = default(HeaderData);","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/FileSystem/FileSystem.cs#L42-L78","documentation":"Constructor guard in the private FileSystem(fullPath, access, stream): thrown when the access parameter equals FileSystemAccess.Unspecified. A file system must be opened with an explicit Read or Write access mode before any operation can be routed correctly; callers must pass a concrete FileSystemAccess value.","triggerScenarios":"Calling FileSystem.Create or FileSystem.Open with FileSystemAccess.Unspecified as the access parameter, often the enum's default value.","commonSituations":"Passing default(FileSystemAccess) which equals Unspecified; deserializing an access mode from config where the value failed to map and fell back to the default enum member.","solutions":["Pass FileSystemAccess.Read or FileSystemAccess.Write explicitly","If access comes from config/settings, validate it is not Unspecified before calling","Avoid using default(FileSystemAccess) or relying on enum zero-values for this API","Check config parsing: an invalid enum string may silently produce the default member"],"exampleFix":"// before\nvar fs = FileSystem.Create(path, default(FileSystemAccess), stream, ...);\n// after\nvar access = FileSystemAccess.Write; // choose explicitly\nvar fs = FileSystem.Create(path, access, stream, ...);","handlingStrategy":"validation","validationCode":"if (access == FileSystemAccess.Unspecified) throw new ArgumentException(\"access must be Read or Write\", nameof(access));\nFileSystem.Create(fullPath, access, stream, maxFileCount, maxBlockCount);","typeGuard":"bool IsSpecifiedAccess(FileSystemAccess a) => a == FileSystemAccess.Read || a == FileSystemAccess.Write;","tryCatchPattern":"try { var fs = FileSystem.Create(path, access, stream, fc, bc); }\ncatch (GameFrameworkException ex) when (ex.Message == \"Access is invalid.\") { Log.Error($\"Unspecified access for {path}\"); }","preventionTips":["Always pass an explicit Read or Write access mode","Never rely on default(FileSystemAccess)","Validate enum values parsed from config before use"],"tags":["gameframework","filesystem","enum-validation"],"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-15T23:17:13.987Z"}