Skip to content

"Cannot read properties of undefined (reading 'map')" when running ui5lint #583

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

Closed
Lemonron opened this issue Mar 4, 2025 · 6 comments · Fixed by #601
Closed

"Cannot read properties of undefined (reading 'map')" when running ui5lint #583

Lemonron opened this issue Mar 4, 2025 · 6 comments · Fixed by #601

Comments

@Lemonron
Copy link

Lemonron commented Mar 4, 2025

Expected Behavior

ui5lint running successfully

Current Behavior

10:55 $ node -v
v22.14.0

10:55 $ npm -v
10.9.2

10:55 $ npm install --global @ui5/linter

changed 336 packages in 4s

69 packages are looking for funding
  run `npm fund` for details

10:55 $ ui5lint --version
1.11.0 (from /opt/homebrew/lib/node_modules/@ui5/linter/bin/ui5lint.js)

10:55 $ ui5lint

⚠️  Process Failed With Error

Error Message:
Cannot read properties of undefined (reading 'map')

Stack Trace:
TypeError: Cannot read properties of undefined (reading 'map')
    at new TraceMap (file:///opt/homebrew/lib/node_modules/@ui5/linter/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs:319:40)
    at new SourceFileReporter (file:///opt/homebrew/lib/node_modules/@ui5/linter/lib/linter/ui5Types/SourceFileReporter.js:26:34)
    at new SourceFileLinter (file:///opt/homebrew/lib/node_modules/@ui5/linter/lib/linter/ui5Types/SourceFileLinter.js:69:26)
    at TypeChecker.lint (file:///opt/homebrew/lib/node_modules/@ui5/linter/lib/linter/ui5Types/TypeLinter.js:119:32)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async lintWorkspace (file:///opt/homebrew/lib/node_modules/@ui5/linter/lib/linter/lintWorkspace.js:49:5)
    at async lint (file:///opt/homebrew/lib/node_modules/@ui5/linter/lib/linter/linter.js:143:17)
    at async lintProject (file:///opt/homebrew/lib/node_modules/@ui5/linter/lib/linter/linter.js:55:17)
    at async UI5LinterEngine.lint (file:///opt/homebrew/lib/node_modules/@ui5/linter/lib/index.js:16:20)
    at async Object.handleLint [as handler] (file:///opt/homebrew/lib/node_modules/@ui5/linter/lib/cli/base.js:121:17)

If you think this is an issue of the ui5-linter, you might report it using the following URL: https://github.com/SAP/ui5-linter/issues/new/choose

Steps to Reproduce the Issue

See current behavior

Context

  • UI5 linter version: 1.11.0
  • Node.js version: 22.14.0 (also occurs in 23.9.0)
  • npm version: 10.9.2
  • OS/Platform: macOS Sequoia 15.3.1

Log Output / Stack Trace

See current behavior

@Lemonron Lemonron added the bug label Mar 4, 2025
@matz3
Copy link
Member

matz3 commented Mar 4, 2025

Hey @Lemonron!

Thank you for reporting this issue.

Could you please enable the --verbose option so that more details are revealed.
This issue most likely happens in one specific place in your code, so it is necessary to identify that file and ideally you can provide the contents of it, so we can debug this specific case.

Thanks 👍🏻

@Lemonron
Copy link
Author

Lemonron commented Mar 4, 2025

I redacted some things, I hope it's still readeable.

11:08 $ npm install --global @ui5/linter

removed 1 package, and changed 336 packages in 7s

69 packages are looking for funding
  run `npm fund` for details
✔ ~/repos/redacted [main|✔] 
11:18 $ ui5lint --verbose
verb cli:middlewares:base using ui5lint version 1.11.0 (from /opt/homebrew/lib/node_modules/@ui5/linter/bin/ui5lint.js)
verb cli:middlewares:base using node version v22.14.0
verb generateProjectGraph Creating project graph using object...
verb graph:Module Could not find any build manifest in module ui5-linter-target
verb graph:Module Configuration for module ui5-linter-target is provided in YAML file at /Users/redacted/repos/redacted/ui5.yaml
verb specifications:types:Application Path mapping for application project com.redacted:
verb specifications:types:Application   Physical root path: /Users/redacted/repos/redacted
verb specifications:types:Application   Mapped to: webapp
verb specifications:types:Application Namespace of project com.redacted is com/redacted(from manifest.json)
verb graph:Module Module ui5-linter-target contains project com.redacted
verb graph:projectGraphBuilder Root project com.redacted qualified as application project for project graph
verb graph:ProjectGraph Adding project: com.redacted
verb graph:ProjectGraph Skipping resolution of optional dependencies since none have been declared
perf Trace Project Graph creation took 273.82 ms
perf Trace Linting manifest.json files took 14.97 ms
perf Trace ts.createProgram took 2.15 s ⚠ (slow)
perf Trace program.getTypeChecker took 0.00 ms

⚠️  Process Failed With Error

Error Message:
Cannot read properties of undefined (reading 'map')

Stack Trace:
TypeError: Cannot read properties of undefined (reading 'map')
    at new TraceMap (file:///opt/homebrew/lib/node_modules/@ui5/linter/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs:319:40)
    at new SourceFileReporter (file:///opt/homebrew/lib/node_modules/@ui5/linter/lib/linter/ui5Types/SourceFileReporter.js:26:34)
    at new SourceFileLinter (file:///opt/homebrew/lib/node_modules/@ui5/linter/lib/linter/ui5Types/SourceFileLinter.js:69:26)
    at TypeChecker.lint (file:///opt/homebrew/lib/node_modules/@ui5/linter/lib/linter/ui5Types/TypeLinter.js:119:32)
    at async lintWorkspace (file:///opt/homebrew/lib/node_modules/@ui5/linter/lib/linter/lintWorkspace.js:49:5)
    at async lint (file:///opt/homebrew/lib/node_modules/@ui5/linter/lib/linter/linter.js:143:17)
    at async lintProject (file:///opt/homebrew/lib/node_modules/@ui5/linter/lib/linter/linter.js:55:17)
    at async UI5LinterEngine.lint (file:///opt/homebrew/lib/node_modules/@ui5/linter/lib/index.js:16:20)
    at async Object.handleLint [as handler] (file:///opt/homebrew/lib/node_modules/@ui5/linter/lib/cli/base.js:121:17)

If you think this is an issue of the ui5-linter, you might report it using the following URL: https://github.com/SAP/ui5-linter/issues/new/choose

@matz3
Copy link
Member

matz3 commented Mar 4, 2025

Ah, I'm sorry, in that case the corresponding file is not included as it fails before it would be logged.

You have to enable --log-level=silly. Feel free to redact all the paths.

The important detail is the file that is linted, which should be logged right before the "Process Failed With Error" message like this:
silly linter:ui5Types:TypeLinter Linting /resources/XYZ

If you could provide that file, and if required, provide a redacted version with which the issue still appears, that would be really helpful for us 👍🏻

@Lemonron
Copy link
Author

Lemonron commented Mar 4, 2025

Oops, it's a file in the "dist" folder. I assume this should not be linted?

silly linter:ui5Types:TypeLinter Linting /resources/com/redacted/dist/Component-preload.js

Everything works smoothly when ignoring the "dist" folder:

12:46 $ ui5lint --ignore-pattern "webapp/dist/**"
UI5 linter report:

0 problems (0 errors, 0 warnings)

Do you still want the file?

@matz3
Copy link
Member

matz3 commented Mar 4, 2025

Ah, okay. Yes, if you put the "dist" folder into "webapp" for whatever reason, you should ignore that folder from linting (e.g. via ui5lint.config). In general, we don't recommend to mix build results with the sources as it may have other implications.

No need to share the file, this can be reproduced with any Component-preload.js.

@Lemonron Lemonron closed this as completed Mar 4, 2025
@matz3
Copy link
Member

matz3 commented Mar 5, 2025

Reopening this issue, as we want to prevent the error from appearing and will maybe log a warning when bundles are linted to still tell the user that something isn't right.

@matz3 matz3 reopened this Mar 5, 2025
@flovogt flovogt removed the bug label Mar 6, 2025
matz3 added a commit that referenced this issue Mar 12, 2025
This fixes an exception that was happening when a source map with
sections was being processed.
It mainly occurred when a UI5 bundle such as a `Component-preload.js` is
part of the project sources and not excluded from linting.

UI5 bundles are now excluded from linting and AMD transpilation.
In addition, source maps with sections are not processed.

Fixes: #583
@matz3 matz3 closed this as completed in 28ab574 Mar 14, 2025
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 a pull request may close this issue.

3 participants