Skip to content

Bug: Backend TypeError crash when GitHub Repos API returns error #61

Description

@Tanishkkkkk

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

  1. Trigger a condition where the GitHub API returns an error (e.g., expired token, rate limits).
  2. Query the /github/languages endpoint.
  3. 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.

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