{"record":{"id":"ca65a0869aeb5c02","repo":"BabylonJS/Babylon.js","slug":"unexpected-content-format-contentformat","errorCode":null,"errorMessage":"Unexpected content format: ${contentFormat}","messagePattern":"Unexpected content format: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/dev/loaders/src/glTF/glTFFileLoader.pure.ts","lineNumber":1307,"sourceCode":"                }\r\n            }\r\n\r\n            this._endPerformanceCounter(\"Unpack Binary\");\r\n\r\n            return unpacked;\r\n        });\r\n    }\r\n\r\n    private _unpackBinaryV1Async(dataReader: DataReader, length: number): Promise<IGLTFLoaderData> {\r\n        const ContentFormat = {\r\n            JSON: 0,\r\n        };\r\n\r\n        const contentLength = dataReader.readUint32();\r\n        const contentFormat = dataReader.readUint32();\r\n\r\n        if (contentFormat !== ContentFormat.JSON) {\r\n            throw new Error(`Unexpected content format: ${contentFormat}`);\r\n        }\r\n\r\n        const bodyLength = length - dataReader.byteOffset;\r\n\r\n        const data: IGLTFLoaderData = { json: this._parseJson(dataReader.readString(contentLength)), bin: null };\r\n        if (bodyLength !== 0) {\r\n            const startByteOffset = dataReader.byteOffset;\r\n            data.bin = {\r\n                readAsync: (byteOffset, byteLength) => dataReader.buffer.readAsync(startByteOffset + byteOffset, byteLength),\r\n                byteLength: bodyLength,\r\n            };\r\n        }\r\n\r\n        return Promise.resolve(data);\r\n    }\r\n\r\n    private _unpackBinaryV2Async(dataReader: DataReader, length: number): Promise<IGLTFLoaderData> {\r\n        const ChunkFormat = {\r","sourceCodeStart":1289,"sourceCodeEnd":1325,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/loaders/src/glTF/glTFFileLoader.pure.ts#L1289-L1325","documentation":"Thrown while unpacking a glTF binary v1 container when the first chunk's contentFormat uint32 is not ContentFormat.JSON (0). glTF-Binary v1 requires the initial content chunk to be JSON.","triggerScenarios":"Loading a legacy glb-v1 file whose first chunk format field is wrong or corrupted.","commonSituations":"Very old exporter output; files hand-mangled or re-chunked by custom tooling; confusing v1 containers with v2 chunk layouts.","solutions":["Convert the legacy .glb to glTF 2.0 (gltf-pipeline) so the modern v2 path is used","Fix the chunk header so contentFormat is 0 (JSON)","Re-export with a compliant tool and validate with glTF-Validator"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const dv = new DataView(await file.arrayBuffer());\nif (dv.getUint32(0, true) !== 0x46546c67) throw new Error('not glb');\nif (dv.getUint32(4, true) === 1) {\n  const fmt = dv.getUint32(16, true);\n  if (fmt !== 0) throw new Error('glb-v1 first chunk is not JSON: ' + fmt);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await loader.loadAsync(url);\n} catch (e) {\n  if (e.message?.startsWith('Unexpected content format')) {\n    console.error('Legacy glb-v1 with non-JSON first chunk — convert to glTF 2.0:', e.message);\n  }\n}","preventionTips":["Migrate legacy glb-v1 assets to glTF 2.0","Never hand-edit binary chunk headers","Validate all binaries in CI with glTF-Validator"],"tags":["gltf","binary","file-format"],"backgroundTag":"invalid-file-magic","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}