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] Application: Fallback to manifest.appdescr_variant if manifest.json is not found #631

Merged
merged 2 commits into from
Jul 13, 2023

Conversation

RandomByte
Copy link
Member

@RandomByte RandomByte commented Jul 12, 2023

This fixes a regression presumably present since ui5-project v3.0.0,
which prevented proper fallback to manifest.appdescr_variant in case no
manifest.json is found in the project.

…json is not found

This fixes a regression presumably present since ui5-projevt 3.0.0,
which prevented proper fallback to manifest.appdescr_variant in case no
manifest.json is found in the project.
@RandomByte RandomByte requested a review from a team July 12, 2023 19:10
@coveralls
Copy link

coveralls commented Jul 12, 2023

Coverage Status

coverage: 95.85% (+0.006%) from 95.844% when pulling f57ddbd on fix-application-appdesc-fallback into 557cb36 on main.

@@ -124,15 +124,15 @@ class Application extends ComponentProject {
try {
return await this._getNamespaceFromManifestJson();
} catch (manifestJsonError) {
if (manifestJsonError.code !== "ENOENT") {
if (manifestJsonError.cause?.code !== "ENOENT") {
Copy link
Member

@codeworrior codeworrior Jul 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, I don't like if the caller needs to know the potential structure of an exception chain. However, as this is inside the same module, it's acceptable.

Alternatively, the catch clause starting in line 224 could check for the ENOENT and re-throw the err "as is", without wrapping it. Both error messages anyhow have the same content (no added value).

For the caller this then would result in a direct check on the caught manifestJsonError.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, somehow I missed that 👍

Copy link
Member

@codeworrior codeworrior left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@matz3 matz3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I missing something, or is there still no test case that verifies the described fallback behaviour?

@codeworrior
Copy link
Member

codeworrior commented Jul 13, 2023

@matz3 Something like test/lib/specifications/types/Application.js#L488 ?

The test might need some improvement as it didn't detect the issue that this PR fixes.

[Update] The mentioned test stubbed the error.code and that has hidden the error in the productive code. A test with fixtures instead of stubs would have shown the issue. Alternatively, the result of _getManifest could be tested separately for throwing an error with a property code === "NOENT".

@RandomByte
Copy link
Member Author

Alternatively, the result of _getManifest could be tested separately for throwing an error with a property code === "NOENT".

This is exactly what I did: https://github.com/SAP/ui5-project/pull/631/files#diff-59c51aa221f82a38efbda063367f94782ab12d1b9d63d9e94e3917ca43f89408R589

This assertion would have failed before the fix.

@RandomByte RandomByte merged commit 43c6b22 into main Jul 13, 2023
14 checks passed
@RandomByte RandomByte deleted the fix-application-appdesc-fallback branch July 13, 2023 08:26
@matz3
Copy link
Member

matz3 commented Jul 13, 2023

Got it, thanks.

@tobiasqueck
Copy link

Works like a charm, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants