Skip to content

bug(api): validate invalid user query in /api/streak endpoint #838

Description

@aditigit05

Description

The /api/streak endpoint currently returns a 500 Internal Server Error when the user query parameter is missing, empty, or malformed.

/api/streak?user=http://localhost:3000
/api/streak?user=http://localhost
/api/streak?user=
/api/streak

Instead of handling invalid input gracefully, the API crashes internally and logs repeated errors in the browser console/network tab.

Steps to Reproduce

1)Open the application in the browser.
2)Navigate to the /api/streak endpoint manually.
Test the following invalid queries:
/api/streak?user=http://localhost:3000
/api/streak?user=http://localhost
/api/streak?user=
/api/streak
Observe the API response and browser console/network tab.
Notice that the endpoint returns a 500 Internal Server Error instead of validating the input properly.

Expected Behavior

The API should validate the user query parameter before processing the request.

For invalid, empty, or malformed values, the endpoint should:

  • Return a proper client error response such as 400 Bad Request
  • Show a meaningful error message like "Invalid username"
  • Prevent internal server crashes
  • Avoid repeated error logs in the console/network tab

Example expected response:

{
  "success": false,
  "message": "Invalid or missing user parameter"
}

Screenshots / Logs

No response

GitHub Username (If applicable)

aditigit05

Environment

Chrome

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions