Closed Bug 1868768 Opened 7 months ago Closed 6 months ago

"CallbackHandler:process_action" fails with: "UnboundLocalError: local variable 'result' referenced before assignment"

Categories

(Testing :: web-platform-tests, defect, P3)

defect

Tracking

(firefox123 fixed)

RESOLVED FIXED
123 Branch
Tracking Status
firefox123 --- fixed

People

(Reporter: whimboo, Assigned: jgraham)

References

Details

Attachments

(2 files, 1 obsolete file)

This always causes a problem for a test like the following that would usually timeout:

mach wpt /html/webappapis/system-state-and-capabilities/the-navigator-object/protocol-handler-fragment-nosw.https.html

Running this command I always see:

 0:12.11 WARNING Traceback (most recent call last):
  File "/Users/henrik/code/gecko/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/executormarionette.py", line 879, in run_func
    self.result = True, self.func(self.protocol, self.url, self.timeout)
  File "/Users/henrik/code/gecko/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/executormarionette.py", line 1007, in do_testharness
    done, rv = handler(result)
  File "/Users/henrik/code/gecko/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/base.py", line 742, in __call__
    return callback(url, payload)
  File "/Users/henrik/code/gecko/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/base.py", line 779, in process_action
    self.logger.debug(f"Action {action} completed with result {result}")
UnboundLocalError: local variable 'result' referenced before assignment

The problem here is most likely that we do not run into an AttributeError including the extra if checks and as such result never gets defined.

It doesn't look to be a new issue. James, maybe you could have a look please? Thanks!

Flags: needinfo?(james)

Well if we get an AttributeError that doesn't match the checks we should re-raise, but that's a bug and not something that should happen.

This doesn't repo for me, so maybe you could try the following patch and see what happens:

diff --git a/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/base.py b/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/base.py
index 7ef9c9b54cb41..7c993bcc6e88f 100644
--- a/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/base.py
+++ b/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/base.py
@@ -765,6 +765,7 @@ class CallbackHandler:
                     if ((hasattr(e, "obj") and getattr(e, "obj") == self.protocol) or
                         "'{self.protocol.__class__.__name__}' has no attribute" in str(e)):
                         raise NotImplementedError from e
+                    raise
         except self.unimplemented_exc:
             self.logger.warning("Action %s not implemented" % action)
             self._send_message(cmd_id, "complete", "error", f"Action {action} not implemented")
Flags: needinfo?(james) → needinfo?(hskupin)

With that raise added I see the following error:

  File "/Users/henrik/code/gecko/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/executormarionette.py", line 878, in run_func
    self.result = True, self.func(self.protocol, self.url, self.timeout)
  File "/Users/henrik/code/gecko/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/executormarionette.py", line 1006, in do_testharness
    done, rv = handler(result)
  File "/Users/henrik/code/gecko/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/base.py", line 742, in __call__
    return callback(url, payload)
  File "/Users/henrik/code/gecko/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/base.py", line 759, in process_action
    result = action_handler(payload)
  File "/Users/henrik/code/gecko/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/actions.py", line 290, in __call__
    return self.protocol.rph_registrations.set_rph_registration_mode(mode)
AttributeError: 'MarionetteProtocol' object has no attribute 'rph_registrations'
Flags: needinfo?(hskupin)

But that looks like worth a follow-up bug given that it finally gives the expected failure.

I've added a patch, please try it out locally (this doesn't affect the newer version of Python I'm running, which is why it didn't reproduce for me)

Assignee: nobody → hskupin
Status: NEW → ASSIGNED
Attachment #9367479 - Attachment is obsolete: true

The severity field is not set for this bug.
:jgraham, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(james)
Pushed by james@hoppipolla.co.uk:
https://hg.mozilla.org/integration/autoland/rev/88a4fddb5abe
Fix handling of action_handler AttributeError, r=whimboo
https://hg.mozilla.org/integration/autoland/rev/9d7da058ee6b
Fix wpt metadata for changes, r=whimboo
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/43852 for changes under testing/web-platform/tests
Status: ASSIGNED → RESOLVED
Closed: 6 months ago
Resolution: --- → FIXED
Target Milestone: --- → 123 Branch
Flags: needinfo?(james)
Upstream PR merged by moz-wptsync-bot
Upstream PR merged by moz-wptsync-bot
Regressions: 1873115
Regressions: 1873113
Assignee: hskupin → james
Severity: -- → S3
Priority: -- → P3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: