{"record":{"id":"add44ca67f64ff24","repo":"phaserjs/phaser","slug":"invalid-file-key","errorCode":null,"errorMessage":"Invalid File key: ","messagePattern":"Invalid File key: ","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/loader/File.js","lineNumber":89,"sourceCode":"        /**\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\n        if (!this.key)\n        {\n            throw new Error('Invalid File key: ' + this.key);\n        }\n\n        var url = GetFastValue(fileConfig, 'url');\n\n        if (url === undefined)\n        {\n            url = loader.path + loadKey + '.' + GetFastValue(fileConfig, 'extension', '');\n        }\n        else if (typeof url === 'string' && !url.match(/^(?:blob:|data:|capacitor:\\/\\/|http:\\/\\/|https:\\/\\/|\\/\\/)/))\n        {\n            url = loader.path + url;\n        }\n\n        /**\n         * The URL of the file, not including baseURL.\n         *\n         * Automatically has Loader.path prepended to it if a string.\n         *","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/phaserjs/phaser/blob/41be1e462bc600064e498cba370bfa8c5c055a22/src/loader/File.js#L71-L107","documentation":"File.js:89 throws when `this.key` is falsy after prefix handling. The key is the unique cache identifier; without it the loaded asset cannot be retrieved. `GetFastValue(fileConfig, 'key', false)` defaults to false, and if a `loader.prefix` is set it is prepended but cannot rescue a false base key.","triggerScenarios":"Constructing a File with `new Phaser.Loader.File({ type: 'image' })` (no `key`), or passing `key: ''` / `key: null`. The prefix logic at lines 80-84 only prepends when a base key already exists.","commonSituations":"Dynamic asset loading where a key variable resolves to undefined (e.g. a loop variable not set); writing a loader plugin that omits the key; refactoring and accidentally deleting the `key` line in a config object.","solutions":["Always supply a non-empty, unique `key` in the file config.","Use the typed loader methods (`this.load.image(key, url)`) which enforce the key parameter at the API boundary.","If building keys dynamically, validate they are non-empty strings before calling load."],"exampleFix":"// before\nnew Phaser.Loader.File({ type: 'image', url: 'hero.png' })\n// after\nnew Phaser.Loader.File({ type: 'image', key: 'hero', url: 'hero.png' })","handlingStrategy":"validation","validationCode":"if (!fileConfig.key || typeof fileConfig.key !== 'string') {\n  throw new Error('fileConfig.key must be a non-empty string')\n}\nconst file = new Phaser.Loader.File(fileConfig)","typeGuard":"const hasValidFileKey = (c) => typeof c?.key === 'string' && c.key.length > 0","tryCatchPattern":null,"preventionTips":["Use the typed loader methods which require a key argument.","Validate dynamically-built keys are non-empty strings before loading.","Unit-test loader plugins with empty/undefined keys to fail fast."],"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"}