Page MenuHomePhabricator

Query action does not fetch image description correctly on some images
Open, Needs TriagePublicBUG REPORT

Description

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

params = {
        "action": "query",
        "format": "json",
        "formatversion": "2",
        "prop": "imageinfo",
        "iiprop": "extmetadata",
        "titles": "File:Persicaria_maculosa.jpg"
    }
  • The response should look like the string
{'continue': {'iistart': '2019-09-15T17:56:46Z', 'continue': '||'}, 'query': {'pages': [{'pageid': 82195341, 'ns': 6, 'title': 'File:Persicaria maculosa.jpg', 'imagerepository': 'local', 'imageinfo': [{'extmetadata': {'DateTime': {'value': '2019-09-15 18:01:39', 'source': 'mediawiki-metadata', 'hidden': ''}, 'ObjectName': {'value': 'Persicaria maculosa', 'source': 'mediawiki-metadata', 'hidden': ''}, 'CommonsMetadataExtension': {'value': 1.2, 'source': 'extension', 'hidden': ''}, 'Categories': {'value': 'Featured pictures by The Cosmonaut|Featured pictures of Ontario|Featured pictures of flowers|Featured pictures on Wikipedia, English|Pages with maps|Persicaria maculosa (flowers)|Protected areas of Canada with known IDs|Rouge National Urban Park', 'source': 'commons-categories', 'hidden': ''}, 'Assessments': {'value': 'featured|quality', 'source': 'commons-categories', 'hidden': ''}, 'GPSLatitude': {'value': '43.946619', 'source': 'commons-desc-page', 'hidden': ''}, 'GPSLongitude': {'value': '-79.239120', 'source': 'commons-desc-page', 'hidden': ''}, 'GPSMapDatum': {'value': 'WGS-84', 'source': 'commons-desc-page', 'hidden': ''}, 'ImageDescription': {'value': , 'source': 'commons-desc-page'}, 'DateTimeOriginal': {'value': '2019-09-14', 'source': 'commons-desc-page'}, 'Credit': {'value': '<span class="int-own-work" lang="en">Own work</span>', 'source': 'commons-desc-page', 'hidden': ''}, 'Artist': {'value': '<a href="//commons.wikimedia.org/wiki/User:The_Cosmonaut" title="User:The Cosmonaut">The Cosmonaut</a>', 'source': 'commons-desc-page'}, 'Permission': {'value': '<style data-mw-deduplicate="TemplateStyles:r666199556">.mw-parser-output .responsive-license-cc{clear:both;text-align:center;box-sizing:border-box;width:100%;justify-content:space-around;align-items:center;margin:0.5em auto;background-color:#f9f9f9;border:2px solid #e0e0e0;border-spacing:8px;display:flex}.mw-parser-output .responsive-license-cc div{margin:4px}.mw-parser-output .rlicense-text div{margin:0.5em auto}@media screen and (max-width:640px){.mw-parser-output .responsive-license-cc{flex-flow:column}.mw-parser-output .rlicense-text{order:1}}</style><div class="responsive-license-cc layouttemplate licensetpl mw-content-ltr" lang="en"><div class="rlicense-icons"><img alt="w:en:Creative Commons" src="https://upload.wikimedia.org/wikipedia/commons/thumb/7/79/CC_some_rights_reserved.svg/90px-CC_some_rights_reserved.svg.png" decoding="async" title="w:en:Creative Commons" width="90" height="36" srcset="https://upload.wikimedia.org/wikipedia/commons/thumb/7/79/CC_some_rights_reserved.svg/135px-CC_some_rights_reserved.svg.png 1.5x, https://upload.wikimedia.org/wikipedia/commons/thumb/7/79/CC_some_rights_reserved.svg/180px-CC_some_rights_reserved.svg.png 2x" data-file-width="744" data-file-height="300"><br><img alt="attribution" src="https://upload.wikimedia.org/wikipedia/commons/thumb/1/11/Cc-by_new_white.svg/24px-Cc-by_new_white.svg.png" decoding="async" title="attribution" width="24" height="24" srcset="https://upload.wikimedia.org/wikipedia/commons/thumb/1/11/Cc-by_new_white.svg/36px-Cc-by_new_white.svg.png 1.5x, https://upload.wikimedia.org/wikipedia/commons/thumb/1/11/Cc-by_new_white.svg/48px-Cc-by_new_white.svg.png 2x" data-file-width="64" data-file-height="64"><img alt="share alike" src="https://upload.wikimedia.org/wikipedia/commons/thumb/d/df/Cc-sa_white.svg/24px-Cc-sa_white.svg.png" decoding="async" title="share alike" width="24" height="24" srcset="https://upload.wikimedia.org/wikipedia/commons/thumb/d/df/Cc-sa_white.svg/36px-Cc-sa_white.svg.png 1.5x, https://upload.wikimedia.org/wikipedia/commons/thumb/d/df/Cc-sa_white.svg/48px-Cc-sa_white.svg.png 2x" data-file-width="64" data-file-height="64"></div><div class="rlicense-text"><div class="rlicense-declaration">This file is licensed under the <a href="https://en.wikipedia.org/wiki/en:Creative_Commons" class="extiw" title="w:en:Creative Commons">Creative Commons</a> <a rel="nofollow" class="external text" href="https://creativecommons.org/licenses/by-sa/2.5/ca/deed.en">Attribution-Share Alike 2.5 Canada</a> license.</div><div class="rlicense-desc" style="text-align:left;" lang="en">\n<dl><dd>You are free:\n<ul><li><b>to share</b> – to copy, distribute and transmit the work</li>\n<li><b>to remix</b> – to adapt the work</li></ul></dd>\n<dd>Under the following conditions:\n<ul><li><b>attribution</b> – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.</li>\n<li><b>share alike</b> – If you remix, transform, or build upon the material, you must distribute your contributions under the <a rel="nofollow" class="external text" href="https://creativecommons.org/share-your-work/licensing-considerations/compatible-licenses">same or compatible license</a> as the original.</li></ul></dd></dl></div><span class="licensetpl_link" style="display:none;">https://creativecommons.org/licenses/by-sa/2.5/ca/deed.en</span><span class="licensetpl_short" style="display:none;">CC BY-SA 2.5 ca</span><span class="licensetpl_long" style="display:none;">Creative Commons Attribution-Share Alike 2.5 ca</span><span class="licensetpl_link_req" style="display:none;">true</span><span class="licensetpl_attr_req" style="display:none;">true</span></div><div class="rlicense-country"><div class="center"><div class="floatnone"><img alt="Flag of Canada.svg" src="https://upload.wikimedia.org/wikipedia/commons/thumb/c/cf/Flag_of_Canada.svg/90px-Flag_of_Canada.svg.png" decoding="async" width="90" height="45" class="thumbborder" srcset="https://upload.wikimedia.org/wikipedia/commons/thumb/c/cf/Flag_of_Canada.svg/135px-Flag_of_Canada.svg.png 1.5x, https://upload.wikimedia.org/wikipedia/commons/thumb/c/cf/Flag_of_Canada.svg/180px-Flag_of_Canada.svg.png 2x" data-file-width="1200" data-file-height="600"></div></div></div></div>', 'source': 'commons-desc-page', 'hidden': ''}, 'LicenseShortName': {'value': 'CC BY-SA 2.5 ca', 'source': 'commons-desc-page', 'hidden': ''}, 'UsageTerms': {'value': 'Creative Commons Attribution-Share Alike 2.5 ca', 'source': 'commons-desc-page', 'hidden': ''}, 'AttributionRequired': {'value': 'true', 'source': 'commons-desc-page', 'hidden': ''}, 'LicenseUrl': {'value': 'https://creativecommons.org/licenses/by-sa/2.5/ca/deed.en', 'source': 'commons-desc-page', 'hidden': ''}, 'Copyrighted': {'value': 'True', 'source': 'commons-desc-page', 'hidden': ''}, 'Restrictions': {'value': '', 'source': 'commons-desc-page', 'hidden': ''}, 'License': {'value': 'cc-by-sa-2.5-ca', 'source': 'commons-templates', 'hidden': ''}}}]}]}}

It's hard to find in the response, but I am focusing on 'ImageDescription': {'value':
What happens?:

As you can see, in the value for "ImageDescription" is null

What should have happened instead?:
The value should be 'ImageDescription': {'value': 'English: Blooming lady's thumb (Persicaria maculosa).'
This can be seen on the page for the image https://en.wikipedia.org/wiki/File:Persicaria_maculosa.jpg

Software version (skip for WMF-hosted wikis like Wikipedia):
Skipped

Other information (browser name/version, screenshots, etc.):
I suspect that the image description is not fetched correctly due to the image having this box below it (image below) indicating it was taken in a protected area. I'm not sure how this messes with the API fetching the description, but every other image I have fetched a description for worked and this green box was on none of them.

a.png (90×1 px, 7 KB)

For ease of recreation, this code in Python should work

import requests as requests
def fetch_potd_blurb():
    params = {
        "action": "query",
        "format": "json",
        "formatversion": "2",
        "prop": "imageinfo",
        "iiprop": "extmetadata",
        "titles": "File:Persicaria_maculosa.jpg"
    }

    response = SESSION.get(url=ENDPOINT2, params=params)
    data = response.json()
    print(data)
    if "ImageDescription" in data["query"]["pages"][0]["imageinfo"][0]["extmetadata"]:
        description_raw = data["query"]["pages"][0]["imageinfo"][0]["extmetadata"]["ImageDescription"]["value"]

description_raw should be blank due to the bug.

Event Timeline

Hi @Pbshiver, thanks for taking the time to report this and welcome to Wikimedia Phabricator!

I can confirm for https://commons.wikimedia.org/w/api.php?action=query&format=json&formatversion=2&prop=imageinfo&iiprop=extmetadata&titles=File:Persicaria_maculosa.jpg where ImageDescription is empty.

https://commons.wikimedia.org/w/index.php?title=File:Persicaria_maculosa.jpg&action=edit&section=1 had a linebreak in the line

|Description=
             {{en|Blooming lady's thumb (''Persicaria maculosa'').}}{{Protected areas in Canada|Q26810464}}

I removed that (with my volunteer account) in https://commons.wikimedia.org/w/index.php?title=File%3APersicaria_maculosa.jpg&diff=730606597&oldid=672072430 , let's see if that will change anything (or not) once the caches have caught up.