schizophrenicmaniac opened a new pull request, #21892: URL: https://github.com/apache/echarts/pull/21892
## Brief Information This pull request is in the type of: - [x] bug fixing - [ ] new feature - [ ] others ### What does this PR do? Throws a clear error instead of an internal TypeError when chord/graph/sankey nodes have duplicate or empty names. ### Fixed issues - #21887: [Bug] chord: duplicate or empty node names crash with TypeError instead of a clear error ## Details ### Before: What was the problem? `Graph.addNode()` skips a node whose id is already taken. An empty name counts as a collision too, because `''` isn't null and every unnamed node ends up with the id `''`. `nodeData` still has every item, though, so `Graph.update()` then indexes a node that was never added and throws `TypeError: Cannot set properties of undefined (setting 'dataIndex')`. All three series built through `createGraphFromNodeEdge` crash this way: chord, graph and sankey. ### After: How does it behave after the fixing? `createGraphFromNodeEdge` checks what `addNode()` returns and calls `throwError` when a node is rejected. In dev builds the message names the id and the series type, for example `Duplicate node name or id "a" in chord series. Each node must have a unique name or id.` This input already crashed every time, so charts that worked before are unaffected. Added `test/ut/spec/series/graph.test.ts`, which covers duplicate names, empty names, duplicate ids and the normal case for chord, graph and sankey. ## Document Info One of the following should be checked. - [x] This PR doesn't relate to document changes - [ ] The document should be updated later - [ ] The document changes have been made in apache/echarts-doc#xxx ## Misc ### Security Checking - [ ] This PR uses security-sensitive Web APIs. <!-- PLEASE CHECK IT AGAINST: <https://github.com/apache/echarts/wiki/Security-Checklist-for-Code-Contributors> --> ### ZRender Changes - [ ] This PR depends on ZRender changes (ecomfe/zrender#xxx). ### Related test cases or examples to use the new APIs `test/ut/spec/series/graph.test.ts` ### Merging options - [ ] Please squash the commits into a single one when merging. ### Other information Fixes #21887 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
