Skip to content

Commit b6437fe

Browse files
authored
fix: handle empty xml (#4965)
XML body did not have any children and the logic had runtime error.
1 parent 2a21fc7 commit b6437fe

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/cli/src/prebuild.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,12 @@ export const prebuild = async (options: {
497497
if (documentType === "xml") {
498498
// treat first body child as root
499499
const bodyInstance = instances.get(rootInstanceId);
500-
if (bodyInstance?.children?.[0].type === "id") {
500+
// @todo test empty xml
501+
if (
502+
bodyInstance &&
503+
bodyInstance.children.length > 0 &&
504+
bodyInstance.children[0].type === "id"
505+
) {
501506
rootInstanceId = bodyInstance.children[0].value;
502507
}
503508
// remove all unexpected components

0 commit comments

Comments
 (0)