Page MenuHomePhabricator

Mediawiki API is returning empty strings for 'required' boolean fields
Closed, ResolvedPublic

Description

Some queries to wikimedia API are returning '' (empty string) values for the 'required' (boolean) field.
Examples:

http://meta.wikimedia.org/w/api.php?action=jsonschema&title=MobileWikiAppToCInteraction&revid=10375484

{"title":"MobileWikiAppToCInteraction","description":"Track users as they interact with the ToC","properties":{"action":{"required":"","description":"Which action in the funnel this is representing","type":"string","enum":["open","close","click"]},"appInstallID":{"description":"AppInstallID that's unique to each app install and is used to track user across this and other features in the mobile app","type":"string","required":""}}}

http://meta.wikimedia.org/w/api.php?action=jsonschema&title=MobileWikiAppArticleSuggestions&revid=11448426

{"title":"MobileWikiAppArticleSuggestions","description":"Track when the user views or interacts with the 'read more' suggestions at the bottom of the current article.","properties":{"action":{"required":"","description":"Which user action triggered this event: 'shown' is used when the suggestions are first shown to the user, and 'clicked' is used when the user clicks one of the suggestions.","type":"string","enum":["shown","clicked"]},"appInstallID":{"description":"AppInstallID that's unique to each app install and is used to track user across this and other features in the mobile app","type":"string","required":""},"pageTitle":{"description":"Title of the page currently being viewed","type":"string","required":""},"readMoreList":{"description":"List of page suggestions displayed to the user (separated by a pipe symbol)","type":"string","required":""},"readMoreIndex":{"description":"Index of the suggested page that was clicked (only used with action=clicked)","type":"integer"},"version":{"description":"Revision of the Read More functionality that was presented to the user. Allowed values are:\n0: Old 'Read More' section with three items.\n1: New 'Read Next' section with a single item.","type":"integer","required":""}}}

http://meta.wikimedia.org/w/api.php?action=jsonschema&title=ImageMetricsCorsSupport&revid=11686678

{"title":"ImageMetricsCorsSupport","description":"CORS support stats.","properties":{"xhrSupported":{"type":"boolean","required":"","description":"True if the browser supports CORS AJAX requests (with credentials - older, partial support is undetected)"},"xdomainSupported":{"type":"boolean","required":"","description":"True if the browser supports XDomainRequest (CORS replacement in old IE)"},"imgAttributeSupported":{"type":"boolean","required":"","description":"True if the browser supports the crossorigin attribute in an <img> tag"},"scriptAttributeSupported":{"type":"boolean","required":"","description":"True if the browser supports the crossorigin attribute in a <script> tag"},"scriptLoaded":{"type":"boolean","required":"","description":"True if the crossorigin script has been successfully loaded"},"sanityCheck":{"type":"boolean","required":"","description":"True if a normal script has been successfully loaded"},"country":{"type":"string","description":"Client's country (per geolocation)"},"isHttps":{"type":"boolean","required":"","description":"Whether the content was loaded over https or not"},"isAnon":{"type":"boolean","required":"","description":"Whether the user is logged in or not"},"samplingFactor":{"type":"integer","required":"","description":"Sampling factor"}}}

This issue is breaking EventLogging, because the schema validator fails and terminates EL components.

Event Timeline

mforns raised the priority of this task from to Needs Triage.
mforns updated the task description. (Show Details)
mforns added subscribers: mforns, Milimetric, Legoktm.
mforns set Security to None.
mforns removed a subscriber: bd808.
bd808 triaged this task as Unbreak Now! priority.Apr 28 2015, 10:56 PM
bd808 subscribed.

EventLogging is broken on 1.26wmf3 until this is fixed.

Legoktm claimed this task.

Cherry-picked to 1.26wmf3 and deployed. API responses look good now.

Reopening following reports from @Milimetric that the fix doesn't work for nested elements as shown by https://meta.wikimedia.org/w/api.php?action=jsonschema&title=CentralNoticeBannerHistory&revid=13332080

{
  "title": "CentralNoticeBannerHistory",
  "description": "Summary of recent items in the client-side log of CentralNotice banner events, for CentralNotice campaigns with the banner history feature enabled",
  "properties": {
    "r": {
      "type": "number",
      "required": false,
      "description": "Sampling rate"
    },
    "e": {
      "type": "integer",
      "required": false,
      "description": "UNIX timestamp of the most recent KVStore error (if any such errors were logged on this client)"
    },
    "i": {
      "type": "string",
      "required": false,
      "description": "Unique ID for this log (used to flag which logs led to a donation)"
    },
    "n": {
      "type": "integer",
      "required": true,
      "description": "Total number of entries in the banner history log (may be greater than the number sent here)"
    },
    "l": {
      "type": "array",
      "required": false,
      "description": "Summary contents of the most recent entries in the banner history log on this client. May be truncated if the EventLogging payload is too big.",
      "items": [
        {
          "type": "object",
          "description": "Summary of a banner history log entry",
          "properties": {
            "b": {
              "type": "string",
              "description": "Banner name"
            },
            "c": {
              "type": "string",
              "description": "Campaign name"
            },
            "t": {
              "type": "integer",
              "required": "",
              "description": "Unix timestamp indicating approximate time of the event (+\/- 10 seconds)"
            },
            "s": {
              "type": "string",
              "required": "",
              "description": "Code indicating final status of the event"
            }
          }
        }
      ]
    }
  }
}

Change 234194 had a related patch set uploaded (by BryanDavis):
API: Force 'required' to use bools in nested elements

https://gerrit.wikimedia.org/r/234194

The solution in https://phabricator.wikimedia.org/T110450 is probably better than any work-around here. We can merge and deploy that soon, so you can probably close this unless you all need it for other purposes.

Change 234194 abandoned by BryanDavis:
API: Force 'required' to use bools in nested elements

Reason:
Id62140e does this one better by getting rid of the v1 json format usage.

https://gerrit.wikimedia.org/r/234194

The solution in https://phabricator.wikimedia.org/T110450 is probably better than any work-around here. We can merge and deploy that soon, so you can probably close this unless you all need it for other purposes.

Works for me. Thanks.