Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Fix errors thrown from template analyzer #322

Merged
merged 2 commits into from
Sep 4, 2019
Merged

[FIX] Fix errors thrown from template analyzer #322

merged 2 commits into from
Sep 4, 2019

Conversation

matushorvath
Copy link
Contributor

@matushorvath matushorvath commented Sep 3, 2019

When processing XML tags with no attributes, getAttributeNS throws Errors like this:

(node:9995) UnhandledPromiseRejectionWarning: TypeError: Cannot convert undefined or null to object
    at Function.values (<anonymous>)
    at getAttributeNS (/home/i035043/src/portal-ui/node_modules/@ui5/cli/node_modules/@ui5/builder/lib/lbt/analyzer/XMLTemplateAnalyzer.js:59:22)
    at XMLTemplateAnalyzer._analyzeCoreRequire (/home/i035043/src/portal-ui/node_modules/@ui5/cli/node_modules/@ui5/builder/lib/lbt/analyzer/XMLTemplateAnalyzer.js:306:23)
    at XMLTemplateAnalyzer._analyzeNode (/home/i035043/src/portal-ui/node_modules/@ui5/cli/node_modules/@ui5/builder/lib/lbt/analyzer/XMLTemplateAnalyzer.js:226:10)
    at node.$$.forEach (/home/i035043/src/portal-ui/node_modules/@ui5/cli/node_modules/@ui5/builder/lib/lbt/analyzer/XMLTemplateAnalyzer.js:301:37)
    at Array.forEach (<anonymous>)
    at XMLTemplateAnalyzer._analyzeChildren (/home/i035043/src/portal-ui/node_modules/@ui5/cli/node_modules/@ui5/builder/lib/lbt/analyzer/XMLTemplateAnalyzer.js:301:12)
    at XMLTemplateAnalyzer._analyzeNode (/home/i035043/src/portal-ui/node_modules/@ui5/cli/node_modules/@ui5/builder/lib/lbt/analyzer/XMLTemplateAnalyzer.js:293:8)
    at node.$$.forEach (/home/i035043/src/portal-ui/node_modules/@ui5/cli/node_modules/@ui5/builder/lib/lbt/analyzer/XMLTemplateAnalyzer.js:301:37)
    at Array.forEach (<anonymous>)
(node:9995) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 44)

This is caused by node.$ not existing in getAttributeNS function, and Object.values complaining about being called with undefined as parameter. Fixed by replacing undefined with an empty array.

Thank you for your contribution! 🙌

To get it merged faster, kindly review the checklist below:

Pull Request Checklist

@CLAassistant
Copy link

CLAassistant commented Sep 3, 2019

CLA assistant check
All committers have signed the CLA.

@coveralls
Copy link

coveralls commented Sep 3, 2019

Coverage Status

Coverage increased (+0.005%) to 86.598% when pulling 1eac1ee on matushorvath:patch-1 into 2f9a816 on SAP:master.

When processing XML tags with no attributes, getAttributeNS throws Errors like this:
```
(node:9995) UnhandledPromiseRejectionWarning: TypeError: Cannot convert undefined or null to object
    at Function.values (<anonymous>)
    at getAttributeNS (/home/i035043/src/portal-ui/node_modules/@ui5/cli/node_modules/@ui5/builder/lib/lbt/analyzer/XMLTemplateAnalyzer.js:59:22)
    at XMLTemplateAnalyzer._analyzeCoreRequire (/home/i035043/src/portal-ui/node_modules/@ui5/cli/node_modules/@ui5/builder/lib/lbt/analyzer/XMLTemplateAnalyzer.js:306:23)
    at XMLTemplateAnalyzer._analyzeNode (/home/i035043/src/portal-ui/node_modules/@ui5/cli/node_modules/@ui5/builder/lib/lbt/analyzer/XMLTemplateAnalyzer.js:226:10)
    at node.$$.forEach (/home/i035043/src/portal-ui/node_modules/@ui5/cli/node_modules/@ui5/builder/lib/lbt/analyzer/XMLTemplateAnalyzer.js:301:37)
    at Array.forEach (<anonymous>)
    at XMLTemplateAnalyzer._analyzeChildren (/home/i035043/src/portal-ui/node_modules/@ui5/cli/node_modules/@ui5/builder/lib/lbt/analyzer/XMLTemplateAnalyzer.js:301:12)
    at XMLTemplateAnalyzer._analyzeNode (/home/i035043/src/portal-ui/node_modules/@ui5/cli/node_modules/@ui5/builder/lib/lbt/analyzer/XMLTemplateAnalyzer.js:293:8)
    at node.$$.forEach (/home/i035043/src/portal-ui/node_modules/@ui5/cli/node_modules/@ui5/builder/lib/lbt/analyzer/XMLTemplateAnalyzer.js:301:37)
    at Array.forEach (<anonymous>)
(node:9995) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 44)
```

This is caused by `node.$` not existing in `getAttributeNS` function, and Object.values complaining about being called with `undefined` as parameter.
Fixed by replacing undefined with an empty array.
@matushorvath matushorvath changed the title Fix errors thrown when analyzing templates [FIX] Fix errors thrown from template analyzer Sep 3, 2019
@matushorvath matushorvath marked this pull request as ready for review September 3, 2019 16:28
@matushorvath
Copy link
Contributor Author

matushorvath commented Sep 3, 2019

related commit: b01fd85 PR #304

@martwz
Copy link

martwz commented Sep 3, 2019

Facing similar issues in my build, hope this gets merged soon 😇.

@matz3 matz3 self-assigned this Sep 4, 2019
@matz3 matz3 added the bug Something isn't working label Sep 4, 2019
@matz3
Copy link
Member

matz3 commented Sep 4, 2019

Thanks @matushorvath 👍
I adopted the test case to cover that scenario.

@matz3 matz3 merged commit b7f3795 into SAP:master Sep 4, 2019
@matz3
Copy link
Member

matz3 commented Sep 4, 2019

@martinxxd you could just switch back to UI5 CLI v1.7.0 until a patch is released.
Also, when using lockfiles, this issue only affects new projects, not existing ones as updates don't happen automatically.

@matz3
Copy link
Member

matz3 commented Sep 4, 2019

Released with @ui5/builder v1.5.1 / @ui5/cli v1.8.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants