{"record":{"id":"b4adbf83d8551c17","repo":"apache/echarts","slug":"invalid-data-format","errorCode":null,"errorMessage":"Invalid data format.","messagePattern":"Invalid data format\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/chart/lines/LinesSeries.ts","lineNumber":286,"sourceCode":"            let coordsCursor = 0;\n            let offsetCursor = 0;\n            let dataCount = 0;\n            for (let i = 0; i < len;) {\n                dataCount++;\n                const count = data[i++] as number;\n                // Offset\n                coordsOffsetAndLenStorage[offsetCursor++] = coordsCursor + startOffset;\n                // Len\n                coordsOffsetAndLenStorage[offsetCursor++] = count;\n                for (let k = 0; k < count; k++) {\n                    const x = data[i++] as number;\n                    const y = data[i++] as number;\n                    coordsStorage[coordsCursor++] = x;\n                    coordsStorage[coordsCursor++] = y;\n\n                    if (i > len) {\n                        if (__DEV__) {\n                            throw new Error('Invalid data format.');\n                        }\n                    }\n                }\n            }\n\n            return {\n                flatCoordsOffset: new Uint32Array(coordsOffsetAndLenStorage.buffer, 0, offsetCursor),\n                flatCoords: coordsStorage,\n                count: dataCount\n            };\n        }\n\n        return {\n            flatCoordsOffset: null,\n            flatCoords: null,\n            count: data.length\n        };\n    }","sourceCodeStart":268,"sourceCodeEnd":304,"githubUrl":"https://github.com/apache/echarts/blob/30076aedcd7b7f65d8dd8e8d9ece46ce778133a3/src/chart/lines/LinesSeries.ts#L268-L304","documentation":"DEV-only guard in the LinesSeries flat-coords decoding loop: when a 'lines' series is supplied with flat coordinate data (a flat number array plus a parallel offset/length table), the decoder walks the buffer per segment; if the cursor i runs past len mid-segment the data is malformed and it throws. Stripped in production.","triggerScenarios":"Supplying flat (non-nested) coords data whose offset table claims more points than the buffer actually holds; corrupt or truncated flat arrays; odd-length coordinate buffers.","commonSituations":"Hand-rolled flat-encoding of lines data; serializer that dropped trailing numbers; mismatched coords/offsets tables.","solutions":["Prefer nested coords (number[][]) which is independently validated by error [7]","If using flat data, ensure each segment's count matches the number of x,y pairs present","Re-encode flat data with a vetted helper rather than building it by hand"],"exampleFix":"// before (flat, truncated / odd count)\n{ type: 'lines', data: [{ coords: [116, 39, 121] }] } // 3 numbers\n\n// after (nested, validated)\n{ type: 'lines', data: [{ coords: [[116, 39], [121, 31]] }] }","handlingStrategy":"validation","validationCode":"function validFlat(data: number[]): boolean {\n  return Array.isArray(data) && data.length % 2 === 0;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer nested coords (number[][]) unless flat-data performance is required","Sanity-check flat arrays have even length (each x has a y)","Re-encode flat data with a vetted helper rather than hand-building offset tables"],"tags":["lines-series","flat-data","dev-only"],"backgroundTag":null,"analyzedSha":"30076aedcd7b7f65d8dd8e8d9ece46ce778133a3","analyzedAt":"2026-08-12T12:42:28.134Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}