Bug 1337022 - Fix the regex in the Telemetry event parser. r?dexter draft
authorFederico Padua <federico_padua@yahoo.it>
Fri, 17 Mar 2017 11:59:17 +0100
changeset 500677 f37a668c53aca83bfc4651b5eda5235fcc465dd4
parent 500240 39607304b774591fa6e32c4b06158d869483c312
child 549673 10c441f285d07071ad7af03c5c388e0c44f11596
push id49759
push userbmo:federico_padua@yahoo.it
push dateFri, 17 Mar 2017 11:00:22 +0000
reviewersdexter
bugs1337022
milestone55.0a1
Bug 1337022 - Fix the regex in the Telemetry event parser. r?dexter This patch fixes the regex defined by IDENTIFIER_PATTERN in toolkit/components/telemetry/parse_events.py to be less strict and fixes the relative documentation. To be precise, before this fix, the regex did not allow the category "ui" (which is described in the documentation at the webpage https://gecko.readthedocs.io/en/latest/toolkit/components/telemetry/telemetry/collection/events.html) to be matched so the documentation was wrong. The reason for that was that the regex required at least one extra character or number to be in the string, so for example "uig" would have matched. With this fix the category "ui" is allowed and matched by the new regex and the documentaion (https://gecko.readthedocs.io/en/latest/toolkit/components/telemetry/telemetry/collection/events.html#limits) is updated to reflect the change. MozReview-Commit-ID: ID2aKOM1v7
toolkit/components/telemetry/docs/collection/events.rst
toolkit/components/telemetry/parse_events.py
--- a/toolkit/components/telemetry/docs/collection/events.rst
+++ b/toolkit/components/telemetry/docs/collection/events.rst
@@ -41,17 +41,17 @@ Where the individual fields are:
 - ``value``: ``String``, optional, may be ``null``. This is a user defined value, providing context for the event.
 - ``extra``: ``Object``, optional, may be ``null``. This is an object of the form ``{"key": "value", ...}``, used for events where additional context is needed.
 
 .. _eventlimits:
 
 Limits
 ------
 
-Each ``String`` marked as an identifier is restricted to the following regex pattern: ``^[:alpha:][:alnum:_.]+[:alnum:]$``.
+Each ``String`` marked as an identifier is restricted to the following regex pattern: ``^[:alpha:][:alnum:_.]*[:alnum:]$``.
 
 For the Firefox Telemetry implementation, several fields are subject to limits:
 
 - ``category``: Max. byte length is ``30``.
 - ``method``: Max. byte length is ``20``.
 - ``object``: Max. byte length is ``20``.
 - ``value``: Max. byte length is ``80``.
 - ``extra``: Max. number of keys is ``10``.
--- a/toolkit/components/telemetry/parse_events.py
+++ b/toolkit/components/telemetry/parse_events.py
@@ -10,17 +10,17 @@ import string
 import shared_telemetry_utils as utils
 
 MAX_CATEGORY_NAME_LENGTH = 30
 MAX_METHOD_NAME_LENGTH = 20
 MAX_OBJECT_NAME_LENGTH = 20
 MAX_EXTRA_KEYS_COUNT = 10
 MAX_EXTRA_KEY_NAME_LENGTH = 15
 
-IDENTIFIER_PATTERN = r'^[a-zA-Z][a-zA-Z0-9_.]+[a-zA-Z0-9]$'
+IDENTIFIER_PATTERN = r'^[a-zA-Z][a-zA-Z0-9_.]*[a-zA-Z0-9]$'
 DATE_PATTERN = r'^[0-9]{4}-[0-9]{2}-[0-9]{2}$'
 
 
 def nice_type_name(t):
     if isinstance(t, basestring):
         return "string"
     return t.__name__