Open Bug 1477156 Opened 6 years ago Updated 2 years ago

mozjexl: Accessing attribute on empty filter expression causes "TypeError: b is undefined" error

Categories

(Firefox :: Normandy Client, defect, P3)

defect

Tracking

()

Tracking Status
firefox61 --- ?
firefox62 --- ?
firefox63 --- affected

People

(Reporter: cpeterson, Unassigned)

References

(Depends on 1 open bug)

Details

I saw the JavaScript exception below from app.normandy.recipe-runner code in my browser console. I didn't see any apparent symptoms from the exception; I was looking in the browser console because I had some unexpected intermittent "site not found" errors for youtube.com. Normandy is checking for compatibility with "Pref Flip Study: WebRender V1 Experiment [Bug 1474484]". I am running 63 nightly on macOS, but my user profile (and extensions) are sync'd with Firefox on a Windows machine. 1532060236984 app.normandy.recipe-runner ERROR Error checking filter for "Pref Flip Study: WebRender V1 Experiment [Bug 1474484]". Filter: [( normandy.channel == 'nightly' && normandy.version >= '63' && normandy.os.isWin && normandy.os.winVersion == 10.0 && normandy.telemetry.main.environment.system.gfx.adapters[.vendorID == '0x10de'].vendorID == '0x10de' )]. Error: "TypeError: b is undefined" Log.jsm:853 App_append resource://gre/modules/Log.jsm:853:9 log resource://gre/modules/Log.jsm:467:7 error resource://gre/modules/Log.jsm:475:5 checkFilter resource://normandy/lib/RecipeRunner.jsm:276:7 throw self-hosted:1239:9
Flags: needinfo?(mcooper)
The immediate cause of this was a recipe on the server with a filter expression that triggered this bug. The root cause is that mozjexl has a bug. The recipe in question has been disabled. I'm going to move this over to the Normandy component, since the remaining work is to fix the underlying bug.
Component: General → Normandy Client
Flags: needinfo?(mcooper)
Product: Shield → Firefox
This recipe has been fixed and relaunched. Leaving open for the Jexl handling, but @mythmon feel free to close if that's being arbitraged elsewhere.
Flags: needinfo?(mcooper)
The remaining work should be handled here.
Flags: needinfo?(mcooper)
Summary: "TypeError: b is undefined" error from "Pref Flip Study: WebRender V1 Experiment [Bug 1474484]" → mozjexl: Accessing attribute on empty filter expression causes "TypeError: b is undefined" error
Priority: -- → P3

:mythmon, is this issue still outstanding? Trying to reproduce it using this code in the Browser Console:

ChromeUtils.import("resource://normandy/lib/RecipeRunner.jsm");
ChromeUtils.import("resource://gre/modules/components-utils/FilterExpressions.jsm");
let ctx = RecipeRunner.getFilterContext({});
let s = "normandy.channel == 'nightly' && normandy.version >= '63' && normandy.os.isWin && normandy.os.winVersion == 10.0 && normandy.telemetry.main.environment.system.gfx.adapters[.vendorID == '0x10de'].vendorID == '0x10de'";
FilterExpressions.eval(s, ctx).then(console.log.bind(console));

... which produces false. I tried some other explicitly-undefined expressions:

FilterExpressions.eval("hi.buddy == true", ctx).then(console.log.bind(console));
FilterExpressions.eval("hi.buddy[.vendorId == true]", ctx).then(console.log.bind(console));

This just produces undefined. I see that https://github.com/mozilla/mozjexl/commit/94e7463958983e8ca188c86017145827ad90f2f1#diff-098f6bcd4621d373cade4e832627b4f6 landed a while ago, and it seems like it's meant to address this kind of problem, but as far as I can tell, we never picked up that change in Firefox. If there's a case here that mozjexl is failing on, could you please provide an example of it? Or is this issue about bringing the new mozjexl into the Firefox source tree?

Flags: needinfo?(mcooper)

It seems like the error depends on all of:

  1. doing filtering ([.foo])
  2. on a defined object
  3. and then accessing a field on it

To that end, this code reproduces the problem for me:

ChromeUtils.import("resource://normandy/lib/RecipeRunner.jsm");
ChromeUtils.import("resource://gre/modules/components-utils/FilterExpressions.jsm");
let ctx = RecipeRunner.getFilterContext({});
let s = "normandy[.foo].bar";
FilterExpressions.eval(s, ctx).then(console.log.bind(console), console.log.bind(console, "error"));
Flags: needinfo?(mcooper)

I have filed https://github.com/mozilla/mozjexl/pull/20 to try to address the issue.

The above-mentioned PR has been merged, but there's no process available to rebuild the vendored toolkit/components/utils/mozjexl.js. This bug therefore depends on one of https://bugzilla.mozilla.org/show_bug.cgi?id=1520362 or https://github.com/mozilla/mozjexl/issues/21.

Depends on: 1520362
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.