RepoSense icon indicating copy to clipboard operation
RepoSense copied to clipboard

Javascript console error when optional title.md file is missing

Open lyuanww opened this issue 8 months ago • 4 comments

Description

When the optional title.md file is not included in a repository, the JavaScript console displays a 404 error. Since this file is optional, the system should gracefully handle its absence without generating console errors.

Current Behavior

  • The frontend attempts to load title.md regardless of whether it exists
  • A 404 "Not Found" error appears in the browser console when the file is missing
Image

lyuanww avatar Apr 19 '25 19:04 lyuanww

Hi, can i work on this issue?

JadeCheah avatar Jun 25 '25 11:06 JadeCheah

@JadeCheah Sure, we'll be happy to have your help.

If you need info about the setup, workflow, PRs etc, you can check out our developer guide. Please make sure closely follow the workflow when making contribution.

CYX22222003 avatar Jun 25 '25 14:06 CYX22222003

@CYX22222003 Hi, I’ve been looking into this issue and found that the 404 error is logged in the browser before the frontend code can catch it, since it's a valid HTTP response (not a network error). This happens even with a HEAD request, as the browser still logs the 404 to the console before JavaScript can handle it.

As far as I know, there's no frontend-only way to check for file existence silently without triggering a console log, because the fetch still results in a 404 response.

Would it make sense to handle this more cleanly from the backend side instead? I tried looking for where the backend serves static files like title.md, but couldn’t find the exact part. If you know where that logic is or have suggestions on how to proceed, I’d really appreciate any pointers.

JadeCheah avatar Jun 28 '25 01:06 JadeCheah

@JadeCheah Here are some ideas on the logic related to the loading and rendering of the static file

Backend:

https://github.com/reposense/RepoSense/blob/4ce97d652765576d5830bdee7787ecbd2f86b14d/src/main/java/reposense/RepoSense.java#L84-L89 This part in the main RepoSense.java is the entry point to the logic where it handles the main analysis of repos as well as loads the static content. The handleZipFileAndFolders will zip and bundle all results of backend logic into the output path (the default is "reposense-report").

https://github.com/reposense/RepoSense/blob/4ce97d652765576d5830bdee7787ecbd2f86b14d/src/main/java/reposense/report/ReportGenerator.java#L175-L178 The generateReport method is in charge of loading the static content using the copyDirectoryContents from the config paths.

https://github.com/reposense/RepoSense/blob/4ce97d652765576d5830bdee7787ecbd2f86b14d/src/main/java/reposense/RepoSense.java#L96-L98

https://github.com/reposense/RepoSense/blob/4ce97d652765576d5830bdee7787ecbd2f86b14d/src/main/java/reposense/system/ReportServer.java#L25-L41

The ReportServer will start the server to serve content from the specified output path. The gradle will load frontend build code to the output directory together with the backend results.

Frontend:

https://github.com/reposense/RepoSense/blob/4ce97d652765576d5830bdee7787ecbd2f86b14d/frontend/src/components/c-title.vue#L17-L29

The title.md is fetched in the c-title element when rendering dashboard on browser.

CYX22222003 avatar Jun 28 '25 02:06 CYX22222003