{"record":{"id":"779c85006b8a4d7d","repo":"phaserjs/phaser","slug":"invalid-file-type","errorCode":null,"errorMessage":"Invalid File type: ","messagePattern":"Invalid File type: ","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/loader/File.js","lineNumber":68,"sourceCode":"         *\n         * @name Phaser.Loader.File#cache\n         * @type {(Phaser.Cache.BaseCache|Phaser.Textures.TextureManager)}\n         * @since 3.7.0\n         */\n        this.cache = GetFastValue(fileConfig, 'cache', false);\n\n        /**\n         * The file type string (image, json, etc) for sorting within the Loader.\n         *\n         * @name Phaser.Loader.File#type\n         * @type {string}\n         * @since 3.0.0\n         */\n        this.type = GetFastValue(fileConfig, 'type', false);\n\n        if (!this.type)\n        {\n            throw new Error('Invalid File type: ' + this.type);\n        }\n\n        /**\n         * Unique cache key (unique within its file type)\n         *\n         * @name Phaser.Loader.File#key\n         * @type {string}\n         * @since 3.0.0\n         */\n        this.key = GetFastValue(fileConfig, 'key', false);\n\n        var loadKey = this.key;\n\n        if (loader.prefix && loader.prefix !== '')\n        {\n            this.key = loader.prefix + loadKey;\n        }\n","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/phaserjs/phaser/blob/41be1e462bc600064e498cba370bfa8c5c055a22/src/loader/File.js#L50-L86","documentation":"File.js:68 throws when `fileConfig.type` is falsy. The `type` string (image, json, atlas, audio, etc.) sorts the File in the Loader and routes it to the right cache; a missing/empty/false type is treated as invalid because the loader cannot place the file. `GetFastValue` defaults it to `false`, so omitting `type` triggers the guard.","triggerScenarios":"Constructing a `new Phaser.Loader.File({ key: 'x', url: 'x.png' })` (or a custom File subclass config) without a `type` field; passing `type: ''` or `type: null`.","commonSituations":"Writing a custom File type/loader plugin and forgetting to set `type` in the config; building a file config dynamically where a branch leaves `type` unset; copy-pasting a config and dropping the `type` line.","solutions":["Add a valid `type` string to the file config (e.g. `'image'`, `'json'`, `'audio'`, `'xml'`).","Prefer the high-level loader APIs (`this.load.image(...)`, `this.load.json(...)`) which set the type internally.","When subclassing File, pass a complete config object including `type` to `super(...)`.","Validate the config object shape before constructing the File."],"exampleFix":"// before\nnew Phaser.Loader.File({ key: 'hero', url: 'hero.png' })\n// after\nnew Phaser.Loader.File({ type: 'image', key: 'hero', url: 'hero.png' })","handlingStrategy":"validation","validationCode":"if (!fileConfig.type || typeof fileConfig.type !== 'string') {\n  throw new Error('fileConfig.type must be a non-empty string')\n}\nconst file = new Phaser.Loader.File(fileConfig)","typeGuard":"const hasValidFileType = (c) => typeof c?.type === 'string' && c.type.length > 0","tryCatchPattern":null,"preventionTips":["Prefer this.load.image/audio/json/etc. which set type internally.","When subclassing File, always include type in the config passed to super.","Validate dynamic file configs with a schema before construction."],"tags":["loader","file","config","validation"],"backgroundTag":null,"analyzedSha":"41be1e462bc600064e498cba370bfa8c5c055a22","analyzedAt":"2026-08-13T04:23:39.729Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}