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] Invalid Path on UI Scan Endpoint - Windows #42

Open
emmanuel39hanks opened this issue Nov 21, 2024 · 0 comments
Open

[BUG] Invalid Path on UI Scan Endpoint - Windows #42

emmanuel39hanks opened this issue Nov 21, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@emmanuel39hanks
Copy link
Contributor

emmanuel39hanks commented Nov 21, 2024

Description

When running the napi ui command in a project, the /api/scan endpoint fails with an Invalid file path error on Windows. The issue occurs because the entrypoint path from the .napirc configuration file is passed as a Windows-style path (e.g., C:\\Users\\emmanuel\\...) to the endpoint.

This bug prevents the napi ui visualizer from scanning the entry point and displaying the codebase structure, making the feature unusable on Windows.

Expected Behavior

The /api/scan endpoint should correctly process the entrypoint path, regardless of whether it’s in Windows-style or Unix-style format, and return a valid response.

Actual Behavior

The /api/scan endpoint fails with the following response:

[
  {
    "code": "custom",
    "message": "Invalid file path",
    "path": ["entrypointPath"]
  }
]

Possible Fix

Normalize file paths to handle both Windows-style (C:\...) and Unix-style (/...) paths.
Use a library like path from Node.js to ensure consistent path handling.

Steps to Reproduce

  1. On a Windows environment create a .napirc file with the following configuration:
{
  "entrypoint": "src/index.js",
  "out": "napi_dist"
}
  1. Run the command:
napi ui
  1. Observe the generated config (e.g., http://localhost:3000/api/config) with Windows-style paths:
{
  "entrypoint": "C:\\Users\\emmanuel\\opensource\\napi\\examples\\express\\src\\index.js",
  "out": "C:\\Users\\emmanuel\\opensource\\napi\\examples\\express\\napi_dist"
}
  1. Check the /api/scan endpoint and see the Invalid file path error.

Context

This bug blocks the ability to use then napi ui command on Windows. It affects Windows developers trying to scan their entrypoint and view their codebase in the visualizer.

Your Environment

  • Version used: napi v0.0.19
  • NodeJS Version: v20.11.0
  • Operating System: Windows 11

Config File

Paste your .napirc below

{
  "entrypoint": "src/index.js",
  "out": "napi_dist"
}
@emmanuel39hanks emmanuel39hanks added the bug Something isn't working label Nov 21, 2024
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

No branches or pull requests

1 participant