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

BUG - ui5-proxy-middleware crashes on startup if the cwd is not the root of the project #1051

Closed
3 tasks
tobiasqueck opened this issue Jun 1, 2023 · 1 comment
Labels
bug Something isn't working ui5-proxy-middleware @sap-ux/ui5-proxy-middleware
Milestone

Comments

@tobiasqueck
Copy link
Contributor

Related Feature

Feature request: issue number

Description

If you have a project with the ui5-proxy-middleware configured in the ui5.yaml and you start it from the outside e.g. ui5 server --config ./my-project/ui5.yaml then the middleware crashes when trying to find the manifest.json.

Steps to Reproduce

Steps to reproduce the behavior:

  1. Generate a project with the SAP Fiori generator
  2. (install the ui5 cli globally)
  3. Run ui5 serve outside the project directory but pointing to the config inside
  4. See error

Expected results

The preview starts as expected,

Actual results

The middleware crashes because it cannot find the manifest.json to read the minUI5Version

Expected fix

This issue requires two fixes

  1. Don't rely on the cwd but use the ui5 tooling provided fs to find project files
  2. Even if a manifest.json is not found e.g. for an adaptation project, the middleware should not crash but just assume the latest UI5 version

Additional Information

Conversation with @petermuessig

The problematic code is the following here which just relies on the current working directory as you also mentioned above:
https://github.com/SAP/open-ux-tools/blob/main/packages/ui5-proxy-middleware/src/base/utils.ts#LL199C11-L199C22

If your middleware would work with the UI5 tooling version 3.0 only, you could run the following code to determine the project root in your custom middleware:

middlewareUtil.getProject().getRootPath()

If you need to support the old and the newer version in parallel having a specVersion < 3.0 then you may do the same workaround as I did in the transpile middleware / task:
https://github.com/ui5-community/ui5-ecosystem-showcase/blob/main/packages/ui5-tooling-transpile/lib/util.js#L291-L307

This function requires the project root collection to be passed, e.g.:
https://github.com/ui5-community/ui5-ecosystem-showcase/blob/main/packages/ui5-tooling-transpile/lib/middleware.js#L31

Screenshots

If applicable, add screenshots to help explain the problem.

Version/Components/Environment

Add any other context about the problem here
OS:

  • Mac OS
  • Windows
  • Other

Root Cause Analysis

Problem

{describe the problem}

Fix

{describe the fix}

Why was it missed

{Some explanation why this issue might have been missed during normal development/testing cycle}

How can we avoid this

{if we don’t want to see this type of issues anymore what we should do to prevent}

@tobiasqueck tobiasqueck added bug Something isn't working ui5-proxy-middleware @sap-ux/ui5-proxy-middleware labels Jun 1, 2023
@tobiasqueck tobiasqueck added this to the UI5Con2023 milestone Jun 1, 2023
@tobiasqueck tobiasqueck changed the title BUG - ui5-proxy-middleware crashes on startup if the cwd is on the root of the project BUG - ui5-proxy-middleware crashes on startup if the cwd is not the root of the project Jun 1, 2023
@tobiasqueck
Copy link
Contributor Author

Fixed with #1054

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ui5-proxy-middleware @sap-ux/ui5-proxy-middleware
Projects
None yet
Development

No branches or pull requests

1 participant