Closed Bug 1936114 Opened 2 months ago Closed 2 months ago

Running xpcshell test through 'mach xpcshell-test' hits AttributeError: 'NoneType' object has no attribute 'get'

Categories

(Testing :: XPCShell Harness, defect)

defect

Tracking

(firefox-esr128 unaffected, firefox133 unaffected, firefox134 unaffected, firefox135 fixed)

RESOLVED FIXED
135 Branch
Tracking Status
firefox-esr128 --- unaffected
firefox133 --- unaffected
firefox134 --- unaffected
firefox135 --- fixed

People

(Reporter: rpl, Assigned: robwu)

References

(Blocks 1 open bug, Regression)

Details

(Keywords: regression, Whiteboard: [addons-jira])

Attachments

(1 file, 1 obsolete file)

Running xpcshell tests locally through mach xpcshell-test command is currently hitting an AttributeError: 'NoneType' object has no attribute 'get' error originated from testing/xpcshell/mach_commands.py line 284.

STR:

  • pull from today's (Dec 9 2024) mozilla-central tip
  • run clobber and build mach commands
  • run ./mach xpcshell-test
    • Expected behavior: xpcshell tests are being executed
    • Actual behavior: AttributeError: 'NoneType' object has no attribute 'get' error riased from testing/xpcshell/mach_commands.py line 284

On the contrary, trying to run xpcshell tests through mach test command doesn't hit the same AttributeError and seems to be working fine, and so it looks like the reason for the issue to not be noticed may be due to the different parameters that mach xpcshell-test and mach test are receiving from their respective callers, and a recent change applied to testing/xpcshell/mach_commands.py to be only expecting the kind of parameters that mach test is consistently getting.

The change that is originating the AttributeError (testing/xpcshell/mach_commands.py line 284) is part of the snap native messaging patches (https://hg.mozilla.org/mozilla-central/rev/f1cfeb19c64250aa762b439736966d81a9a2ecbb#l5.14) and so I'm adding Bug 1661935 in the "Regressed by" bugzilla issue field.

Assignee: nobody → rob
Status: NEW → ASSIGNED
Whiteboard: [addons-jira]

Set release status flags based on info from the regressing bug 1661935

Blocks: 1936158
Pushed by rob@robwu.nl: https://hg.mozilla.org/integration/autoland/rev/81df59628dd3 Fix "mach xpcshell-test" regression (AttributeError) r=gerard-majax,rpl
Status: ASSIGNED → RESOLVED
Closed: 2 months ago
Resolution: --- → FIXED
Target Milestone: --- → 135 Branch

I'm not sure if this is something on my end, but for me the change in the big is causing ./mach test browser/components/newtab/test/ --headless to fail for me.

(In reply to Scott [:thecount] Downe from comment #5)

I'm not sure if this is something on my end, but for me the change in the big is causing ./mach test browser/components/newtab/test/ --headless to fail for me.

yes, it does definitely look related to the change applied from this bug.

It is hitting a KeyError when trying to retrieve the tags key from the manifest parameter, and KeyError was explicitly caught to handle that case in the previous version but it is not in the tweaks applied from this bug.

KeyError: 'tags'

  File "/.../mozilla-central/testing/mach_commands.py", line 454, in test
    res = command_context._mach_context.commands.dispatch(
  File "/.../mozilla-central/python/mach/mach/registrar.py", line 208, in dispatch
    return self._run_command_handler(handler, context, **kwargs)
  File "/.../mozilla-central/python/mach/mach/registrar.py", line 126, in _run_command_handler
    result = fn(instance, **kwargs)
  File "/.../mozilla-central/testing/xpcshell/mach_commands.py", line 286, in run_xpcshell_test
    tags = " ".join(params["manifest"].get("tags", "")).split(" ")
  File "/.../mozilla-central/testing/mozbase/manifestparser/manifestparser/manifestparser.py", line 416, in get
    return [test[_key] for test in tests]
  File "/.../mozilla-central/testing/mozbase/manifestparser/manifestparser/manifestparser.py", line 416, in <listcomp>
    return [test[_key] for test in tests]

Rob, would you mind to take care of that? either in this bug or in a separate followup.

Flags: needinfo?(rob)

I thought that params["manifest"] is a dict, which would not throw KeyError if a default is provided.

Apparently it is a different type, with a different signature for get, so I'll fix this up.

Flags: needinfo?(rob)
Attached file Bug 1936114 - Catch uncaught KeyError (obsolete) —

This restores the "try-except KeyError" that was erroneously dropped in
https://hg.mozilla.org/mozilla-central/rev/81df59628dd3

A patch has been attached on this bug, which was already closed. Filing a separate bug will ensure better tracking. If this was not by mistake and further action is needed, please alert the appropriate party. (Or: if the patch doesn't change behavior -- e.g. landing a test case, or fixing a typo -- then feel free to disregard this message)

Regressions: 1936926

Comment on attachment 9442999 [details]
Bug 1936114 - Catch uncaught KeyError

Revision D231829 was moved to bug 1936926. Setting attachment 9442999 [details] to obsolete.

Attachment #9442999 - Attachment is obsolete: true
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: