Potential bug in GraphQL API. Requesting repository languages returns duplicate objects.

I’ve noticed an odd behaviour (potentially a bug) in the GraphQL repository languages endpoint. Code to replicate behaviour is given below (Python 3.7)

import requests
import json

query = '''
    query {
        nodes(ids:"MDEwOlJlcG9zaXRvcnkxNTQwNTIxMjM=") {
            ... on Repository {
            id
            languages(first:100) {
                totalCount
                edges {
                    size
                    language:node {
                        color
                        id
                        name
                        }
                    }
                }
            }
        }
    }'''

token = "API_ACCESS_TOKEN"
r = requests.post(f"https://api.github.com/graphql",
        json={'query': query},
        headers={'Authorization': f"Bearer {token}"})

print(json.dumps(r.json(), indent=4))

The response is

{
    "data": {
        "nodes": [
            {
                "id": "MDEwOlJlcG9zaXRvcnkxNTQwNTIxMjM=",
                "languages": {
                    "totalCount": 8,
                    "edges": [
                        {
                            "size": 234,
                            "language": {
                                "color": "#384d54",
                                "id": "MDg6TGFuZ3VhZ2U1MzU=",
                                "name": "Dockerfile"
                            }
                        },
                        {
                            "size": 3693,
                            "language": {
                                "color": "#89e051",
                                "id": "MDg6TGFuZ3VhZ2UxMzk=",
                                "name": "Shell"
                            }
                        },
                        {
                            "size": 2644,
                            "language": {
                                "color": "#f1e05a",
                                "id": "MDg6TGFuZ3VhZ2UxNDA=",
                                "name": "JavaScript"
                            }
                        },
                        {
                            "size": 306,
                            "language": {
                                "color": "#563d7c",
                                "id": "MDg6TGFuZ3VhZ2UzMDg=",
                                "name": "CSS"
                            }
                        },
                        {
                            "size": 310,
                            "language": {
                                "color": "#384d54",
                                "id": "MDg6TGFuZ3VhZ2U1MzU=",
                                "name": "Dockerfile"
                            }
                        },
                        {
                            "size": 4085,
                            "language": {
                                "color": "#89e051",
                                "id": "MDg6TGFuZ3VhZ2UxMzk=",
                                "name": "Shell"
                            }
                        },
                        {
                            "size": 2896,
                            "language": {
                                "color": "#f1e05a",
                                "id": "MDg6TGFuZ3VhZ2UxNDA=",
                                "name": "JavaScript"
                            }
                        },
                        {
                            "size": 306,
                            "language": {
                                "color": "#563d7c",
                                "id": "MDg6TGFuZ3VhZ2UzMDg=",
                                "name": "CSS"
                            }
                        }
                    ]
                }
            }
        ]
    }
}

Entries for Dockerfile, Shell, CSS, and Javascript are duplicated and have different size value. Is this behaviour expected? If so, how can I interpret this?

1 Like