{"record":{"id":"f368c177fc7d1927","repo":"gchq/CyberChef","slug":"no-valid-id3-header","errorCode":null,"errorMessage":"No valid ID3 header.","messagePattern":"No valid ID3 header\\.","errorType":"exception","errorClass":"OperationError","httpStatus":null,"severity":"error","filePath":"src/core/operations/ExtractID3.mjs","lineNumber":46,"sourceCode":"        this.outputType = \"JSON\";\n        this.presentType = \"html\";\n        this.args = [];\n    }\n\n    /**\n     * @param {ArrayBuffer} input\n     * @param {Object[]} args\n     * @returns {JSON}\n     */\n    run(input, args) {\n        input = new Uint8Array(input);\n\n        /**\n         * Extracts the ID3 header fields.\n         */\n        function extractHeader() {\n            if (!Array.from(input.slice(0, 3)).equals([0x49, 0x44, 0x33]))\n                throw new OperationError(\"No valid ID3 header.\");\n\n            const header = {\n                \"Type\": \"ID3\",\n                // Tag version\n                \"Version\": input[3].toString() + \".\" + input[4].toString(),\n                // Header version\n                \"Flags\": input[5].toString()\n            };\n\n            input = input.slice(6);\n            return header;\n        }\n\n        /**\n         * Converts the size fields to a single integer.\n         *\n         * @param {number} num\n         * @returns {string}","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/gchq/CyberChef/blob/4290ea753912378913b1f3f54e0fc5720afeda5d/src/core/operations/ExtractID3.mjs#L28-L64","documentation":"Thrown by the Extract ID3 operation when the first three bytes of the input do not match the ID3 magic bytes 'ID3' (0x49, 0x44, 0x33). This indicates the input either has no ID3v2 tag, is not an MP3, or the tag is at a non-zero offset. Only files beginning with a valid ID3v2 header can be parsed.","triggerScenarios":"run(input, args) where Array.from(input.slice(0,3)).equals([0x49,0x44,0x33]) returns false. The input is converted to Uint8Array at line 39 and the header check runs in extractHeader() at line 45.","commonSituations":"Feeding an MP3 that only has ID3v1 tags (at end of file), an MP3 with no tags, a WAV/FLAC file, or any non-MP3 binary. Also occurs when the ID3v2 tag is not at the very start of the file.","solutions":["Ensure the input is an MP3 file that begins with an ID3v2 tag.","Use the Extract Audio Metadata operation instead for broader format support including ID3v1.","Check that no upstream operation has stripped or offset the ID3 header.","Verify the first bytes are literally 'ID3' in a hex viewer."],"exampleFix":"// before: input = WAV file or MP3 with only ID3v1 -> first bytes != 'ID3'\n\n// after: input = MP3 beginning with ID3v2 header (bytes: 49 44 53 ...)","handlingStrategy":"type-guard","validationCode":"// Verify first 3 bytes are 'ID3' magic before calling ExtractID3\nconst bytes = new Uint8Array(input);\nif (bytes.length < 3 || bytes[0] !== 0x49 || bytes[1] !== 0x44 || bytes[2] !== 0x33) {\n  throw new Error('Input does not start with an ID3v2 header');\n}","typeGuard":"function hasID3v2Header(input) {\n  const bytes = new Uint8Array(input);\n  return bytes.length >= 3 && bytes[0] === 0x49 && bytes[1] === 0x44 && bytes[2] === 0x33;\n}","tryCatchPattern":null,"preventionTips":["Check the first 3 bytes for 'ID3' magic before running.","Use Extract Audio Metadata for broader MP3 tag support including ID3v1.","Verify the file is an MP3 with an ID3v2 tag at offset 0."],"tags":["audio","id3","mp3","header-validation","input-validation"],"backgroundTag":null,"analyzedSha":"4290ea753912378913b1f3f54e0fc5720afeda5d","analyzedAt":"2026-08-13T06:05:50.210Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}