{"record":{"id":"d9456e9795b93c01","repo":"unoplatform/uno","slug":"item-guid-is-of-an-unknown-type-you-cannot-use","errorCode":null,"errorMessage":"Item ${guid} is of an unknown type. You cannot use it as a File!","messagePattern":"Item (.+?) is of an unknown type\\. You cannot use it as a File!","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/Uno.UWP/ts/Windows/Storage/NativeStorageItem.ts","lineNumber":36,"sourceCode":"\n\t\tpublic static getItem(guid: string): FileSystemHandle|File {\n\t\t\treturn NativeStorageItem._guidToItemMap.get(guid);\n\t\t}\n\n\t\tpublic static async getFile(guid: string): Promise<File> {\n\t\t\tconst item = NativeStorageItem.getItem(guid);\n\n\t\t\tif (item instanceof File) {\n\t\t\t\treturn item as File;\n\t\t\t}\n\t\t\tif (item instanceof FileSystemFileHandle) {\n\t\t\t\treturn await (item as FileSystemFileHandle).getFile();\n\t\t\t}\n\t\t\tif (item instanceof FileSystemDirectoryHandle) {\n\t\t\t\tthrow new Error(\"Item \" + guid + \" is a directory handle. You cannot use it as a File!\");\n\t\t\t}\n\n\t\t\tthrow new Error(\"Item \" + guid + \" is of an unknown type. You cannot use it as a File!\");\n\t\t}\n\n\t\tpublic static getGuid(item: FileSystemHandle | File): string {\n\t\t\treturn NativeStorageItem._itemToGuidMap.get(item);\n\t\t}\n\n\t\tpublic static getInfos(...items: Array<FileSystemHandle|File>): NativeStorageItemInfo[] {\n\t\t\tconst itemsWithoutGuids: Array<FileSystemHandle|File> = [];\n\n\t\t\tfor (const item of items) {\n\t\t\t\tconst guid = NativeStorageItem.getGuid(item);\n\t\t\t\tif (!guid) {\n\t\t\t\t\titemsWithoutGuids.push(item);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tNativeStorageItem.storeItems(itemsWithoutGuids);\n","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/unoplatform/uno/blob/04183404888ea21b4e5bfa3493e8d5f15e972c3a/src/Uno.UWP/ts/Windows/Storage/NativeStorageItem.ts#L18-L54","documentation":"Thrown by NativeStorageItem.getFile as a catch-all when the item stored under the guid is neither a File, a FileSystemFileHandle, nor a FileSystemDirectoryHandle. This indicates the registered object is an unexpected/unsupported type — getItem returned undefined or an object of an unrecognized class.","triggerScenarios":"The guid passed to getFile does not exist in _guidToItemMap (getItem returns undefined), or the stored item is a non-standard object type. This can happen if the guid was never registered, was already removed, or a non-FileSystem/File object was added.","commonSituations":"Stale guid after the item was removed via removeItem; a guid mismatch between registration and retrieval; a polyfill or browser that returns a different object type for drag-drop items.","solutions":["Verify the guid exists via getItem(guid) before calling getFile, and handle undefined gracefully.","Ensure addItem was called with a valid FileSystemHandle or File object."],"exampleFix":"// before\nconst file = await NativeStorageItem.getFile(guid); // unknown type → throws\n\n// after\nconst item = NativeStorageItem.getItem(guid);\nif (!item) {\n    throw new Error(`No item registered for guid ${guid}`);\n}\nif (!(item instanceof File) && !(item instanceof FileSystemFileHandle)) {\n    throw new Error(`Item ${guid} is not a file (${item.constructor.name})`);\n}\nconst file = await NativeStorageItem.getFile(guid);","handlingStrategy":"validation","validationCode":"const item = NativeStorageItem.getItem(guid);\nif (!item) {\n    throw new Error(`No item for guid ${guid} — register it first`);\n}\nawait NativeStorageItem.getFile(guid);","typeGuard":"function isKnownStorageItem(item: unknown): boolean {\n    return item instanceof File\n        || item instanceof FileSystemFileHandle\n        || item instanceof FileSystemDirectoryHandle;\n}","tryCatchPattern":"try {\n    const file = await NativeStorageItem.getFile(guid);\n} catch (e) {\n    if (e.message.includes('unknown type')) {\n        // item is missing or unsupported — re-register or skip\n    } else { throw e; }\n}","preventionTips":["Verify getItem(guid) returns a value before calling getFile.","Only register File or FileSystemHandle objects via addItem.","Track guid lifecycle to avoid using stale/removed guids."],"tags":["wasm","storage","file-system-access","validation","typescript"],"backgroundTag":null,"analyzedSha":"04183404888ea21b4e5bfa3493e8d5f15e972c3a","analyzedAt":"2026-08-13T21:08:11.651Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}