Skip to content

[BUG] /user/:username returns HTTP 200 with blank profile for non-existent usernames instead of 404 #275

Description

@Tamcodes4

Description

Navigating to /user/<any-made-up-name> returns HTTP 200 and renders the full user profile shell. The page title shows "Performance Profile: @", all stats are blank, and charts are empty. There is no error state shown to the visitor and the browser reports a successful page load.

Steps to Reproduce

  1. Start the server locally.
  2. Navigate to /user/this-user-does-not-exist.
  3. Observe: HTTP 200, full page renders with heading "Performance Profile: @this-user-does-not-exist", blank charts, blank stats, no error message.

Expected Behavior

A non-existent username should produce a visible error, either a 404 response from the server, or at minimum a clear in-page error message that the user could not be found, consistent with how /leaderboard handles data load failures via its #leaderboard-error element.

Actual Behavior

HTTP 200 is returned for any username string. fetchUserData() in historical-graphs.js catches the API error but only console.logs it, no in-page feedback:

} catch (error) {
  console.log("error loading performance statics: ", error);
}

The page renders as if it loaded successfully, just with no data.

Root Cause

Two separate gaps:

server.js (line 135): The route serves user.html for any :username value without checking whether that user exists in the data:

app.get("/user/:username", (req, res) => {
  serveHtml(res, path.join(__dirname, "frontend", "user.html"));
});

frontend/js/user/historical-graphs.js (line 39): The fetch error is silently swallowed with no UI update:

} catch (error) {
  console.log("error loading performance statics: ", error);
}

Suggested Fix

In historical-graphs.js, show a visible error element on fetch failure, matching the pattern used in leaderboard.html:

} catch (error) {
  console.log("error loading performance statics: ", error);
  const errorEl = document.getElementById("profile-error");
  if (errorEl) errorEl.style.display = "block";
}

Add a corresponding #profile-error element to user.html
Optionally, the server route can validate the username against the data repo before serving the page and return a 404 for unknown users.

Affected Files

  • server.js
  • frontend/js/user/historical-graphs.js
  • frontend/user.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions