Types for Glean event extra fields are not enforced in Firefox
Categories
(Data Platform and Tools :: Glean: SDK, defect, P5)
Tracking
(Not tracked)
People
(Reporter: zombie, Unassigned)
Details
It looks like Glean in Firefox will happily accept a string in a quantity
field, and post a ping with it, without throwing from the testGetValue() method even.
If a later part of the pipeline does choose to enforce them, this could be a problematic footgun.
https://phabricator.services.mozilla.com/D192907#inline-1070890
Comment 1•2 years ago
|
||
These are event extras. They are always sent as strings.
The type annotation is used for generating the local API. Now the problem of course is that JavaScript is not really strict about types and we right now don't generate strict runtime checks on those.
testGetValue
just returns what is currently stored and doesn't do any type checks on those anyway.
Nothing in the data pipeline will break because of this. When looking at the data and comparing with the docs of course one could get confused.
Comment 2•2 years ago
|
||
There's an additional Firefox Desktop-specific wrinkle in that, unless we're willing to create a JS webidl type per event, the GleanEvent interface must take extras as a map of strings to strings. In C++ and Rust we have cheap(ish) parameterized types so we're able to enforce type safety using the type system (e.g. we have PageLoadExtra
which is used for recording the perf.page_load
event).
Alas, this is the best we find ourselves able to offer in JS at this time. A (again, per event) runtime typecheck in C++ of JS data would be possible, so I'm not closing this bug... but I don't think I can prioritize that work very highly for the foreseeable future.
Description
•