Page MenuHomePhabricator

SDC wbgetentities API returns a list instead of a dictionary when there is no statements
Closed, DuplicatePublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

  • Find File with labels but without any statements (ie. mediainfo exists, but there is no statements)
  • Query File with API and with JSON output

What happens?:

Result type of empty statements is [] (a list) . In Wikidata type of empty values is {}(dictionary)

{
    "entities": {
        "M34247901": {
            "pageid": 34247901,
            "ns": 6,
            "title": "File:Crater Barabashov based on day THEMIS.png",
            "lastrevid": 793186644,
            "modified": "2023-08-15T10:56:28Z",
            "type": "mediainfo",
            "id": "M34247901",
            "labels": {
                "en": {
                    "language": "en",
                    "value": "Image of Barabashov crater on Mars."
                },
                "cs": {
                    "language": "cs",
                    "value": "Snímek kráteru Barabashov na povrchu Marsu."
                }
            },
            "descriptions": {},
            "statements": []
        }
    },
    "success": 1
}

What should have happened instead?:
Value of empty statements should be empty dictionary: {}

Example request from Wikidata: https://www.wikidata.org/w/api.php?action=wbgetentities&format=json&ids=Q121462814&formatversion=2

{
    "entities": {
        "Q121462814": {
            "pageid": 115877382,
            "ns": 0,
            "title": "Q121462814",
            "lastrevid": 1954259543,
            "modified": "2023-08-15T10:42:10Z",
            "type": "item",
            "id": "Q121462814",
            "labels": {
                "de": {
                    "language": "de",
                    "value": "A selection from the collection of drawings by the old masters formed"
                }
            },
            "descriptions": {
                "de": {
                    "language": "de",
                    "value": "1905"
                }
            },
            "aliases": {},
            "claims": {},
            "sitelinks": {}
        }
    },
    "success": 1
}

Other information (browser name/version, screenshots, etc.):
Incorrect type breaks in the pywikibot stable branch 8.3.0.

Related Objects

Event Timeline

Zache renamed this task from SDC wbgetentities returns a list instead of a dictionary when there is no statements to SDC wbgetentities API returns a list instead of a dictionary when there is no statements .Aug 15 2023, 11:15 AM