Summary
If the GitHub API call to fetch repositories fails or returns an error response, repos_response.json() returns a dictionary instead of a list. Slicing the dict using repos[:20] raises a TypeError and crashes the API server.
Steps to Reproduce
- Trigger a condition where the GitHub API returns an error (e.g., expired token, rate limits).
- Query the
/github/languages endpoint.
- The backend throws an HTTP 500 error with a
TypeError: unhashable type: 'slice'.
Expected vs Actual
- Expected: The backend checks the API status and handles the error gracefully.
- Actual: The backend crashes due to dict slicing.
Screenshot
No screenshot available (Backend API response slicing bug).
Suggested Fix
In backend/app/services/github_service.py under get_language_breakdown, verify that the API request is successful (HTTP 200) and that the response is a list before slicing.
Summary
If the GitHub API call to fetch repositories fails or returns an error response,
repos_response.json()returns a dictionary instead of a list. Slicing the dict usingrepos[:20]raises aTypeErrorand crashes the API server.Steps to Reproduce
/github/languagesendpoint.TypeError: unhashable type: 'slice'.Expected vs Actual
Screenshot
No screenshot available (Backend API response slicing bug).
Suggested Fix
In
backend/app/services/github_service.pyunderget_language_breakdown, verify that the API request is successful (HTTP 200) and that the response is a list before slicing.