Skip to content

Pytest-rerunfailures==16.0 causes INTERNALERROR with XFAIL testsΒ #302

@potiuk

Description

@potiuk

The pytest-rerunfailures 16.0 causes INTERNALERROR with XFAIL tests (at least in some cases) with "worker_internal_error" of pytest-xdist

After pytest-rerunfailures 16.0 has been releasesd, our tests started to crash on XFAIL tests in Airflow CI.
This is entirely reproducible with our CI image, and the error goes away after we downgrade to pytest-rerunfailures 15.1

Example failure here https://github.com/apache/airflow/actions/runs/17316803449/job/49161143268?pr=54913#step:4:231 -> I also copied the error below.

How to reproduce it

  1. check-out Airflow be91b42d9044930c991979ffffd69d4e9174d975 commit
  2. Install breeze: uv tool install -e ./dev/breeze
  3. Runbreeze ci-image build --upgrade-to-newer-dependencies (it will build docker container and pull latest pytest-rerunfailures
  4. Run brreze - you will be inside the container
  5. cd shared/secrets_masker
  6. run pytest --color=yes -n auto -> crash
  7. run uv pip install pytest-rerunfailures==15.1 -> only pytest-rerunfaiures is downgraded
  8. run pytest --color=yes -n auto -> NO crash

Error output below:

INTERNALERROR> def worker_internal_error(
INTERNALERROR>         self, node: WorkerController, formatted_error: str
INTERNALERROR>     ) -> None:
INTERNALERROR>         """
INTERNALERROR>         pytest_internalerror() was called on the worker.
INTERNALERROR>
INTERNALERROR>         pytest_internalerror() arguments are an excinfo and an excrepr, which can't
INTERNALERROR>         be serialized, so we go with a poor man's solution of raising an exception
INTERNALERROR>         here ourselves using the formatted message.
INTERNALERROR>         """
INTERNALERROR>         self._active_nodes.remove(node)
INTERNALERROR>         try:
INTERNALERROR> >           assert False, formatted_error
INTERNALERROR> E           AssertionError: Traceback (most recent call last):
INTERNALERROR> E               File "/usr/local/lib/python3.10/site-packages/_pytest/main.py", line 289, in wrap_session
INTERNALERROR> E                 session.exitstatus = doit(config, session) or 0
INTERNALERROR> E               File "/usr/local/lib/python3.10/site-packages/_pytest/main.py", line 343, in _main
INTERNALERROR> E                 config.hook.pytest_runtestloop(session=session)
INTERNALERROR> E               File "/usr/local/lib/python3.10/site-packages/pluggy/_hooks.py", line 512, in __call__
INTERNALERROR> E                 return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
INTERNALERROR> E               File "/usr/local/lib/python3.10/site-packages/pluggy/_manager.py", line 120, in _hookexec
INTERNALERROR> E                 return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR> E               File "/usr/local/lib/python3.10/site-packages/pluggy/_callers.py", line 167, in _multicall
INTERNALERROR> E                 raise exception
INTERNALERROR> E               File "/usr/local/lib/python3.10/site-packages/pluggy/_callers.py", line 139, in _multicall
INTERNALERROR> E                 teardown.throw(exception)
INTERNALERROR> E               File "/usr/local/lib/python3.10/site-packages/_pytest/logging.py", line 801, in pytest_runtestloop
INTERNALERROR> E                 return (yield)  # Run all the tests.
INTERNALERROR> E               File "/usr/local/lib/python3.10/site-packages/pluggy/_callers.py", line 139, in _multicall
INTERNALERROR> E                 teardown.throw(exception)
INTERNALERROR> E               File "/usr/local/lib/python3.10/site-packages/_pytest/terminal.py", line 688, in pytest_runtestloop
INTERNALERROR> E                 result = yield
INTERNALERROR> E               File "/usr/local/lib/python3.10/site-packages/pluggy/_callers.py", line 121, in _multicall
INTERNALERROR> E                 res = hook_impl.function(*args)
INTERNALERROR> E               File "/usr/local/lib/python3.10/site-packages/xdist/remote.py", line 206, in pytest_runtestloop
INTERNALERROR> E                 self.run_one_test()
INTERNALERROR> E               File "/usr/local/lib/python3.10/site-packages/xdist/remote.py", line 227, in run_one_test
INTERNALERROR> E                 self.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
INTERNALERROR> E               File "/usr/local/lib/python3.10/site-packages/pluggy/_hooks.py", line 512, in __call__
INTERNALERROR> E                 return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
INTERNALERROR> E               File "/usr/local/lib/python3.10/site-packages/pluggy/_manager.py", line 120, in _hookexec
INTERNALERROR> E                 return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR> E               File "/usr/local/lib/python3.10/site-packages/pluggy/_callers.py", line 167, in _multicall
INTERNALERROR> E                 raise exception
INTERNALERROR> E               File "/usr/local/lib/python3.10/site-packages/pluggy/_callers.py", line 139, in _multicall
INTERNALERROR> E                 teardown.throw(exception)
INTERNALERROR> E               File "/usr/local/lib/python3.10/site-packages/_pytest/warnings.py", line 90, in pytest_runtest_protocol
INTERNALERROR> E                 return (yield)
INTERNALERROR> E               File "/usr/local/lib/python3.10/site-packages/pluggy/_callers.py", line 139, in _multicall
INTERNALERROR> E                 teardown.throw(exception)
INTERNALERROR> E               File "/usr/local/lib/python3.10/site-packages/_pytest/assertion/__init__.py", line 192, in pytest_runtest_protocol
INTERNALERROR> E                 return (yield)
INTERNALERROR> E               File "/usr/local/lib/python3.10/site-packages/pluggy/_callers.py", line 139, in _multicall
INTERNALERROR> E                 teardown.throw(exception)
INTERNALERROR> E               File "/usr/local/lib/python3.10/site-packages/_pytest/unittest.py", line 475, in pytest_runtest_protocol
INTERNALERROR> E                 return (yield)
INTERNALERROR> E               File "/usr/local/lib/python3.10/site-packages/pluggy/_callers.py", line 139, in _multicall
INTERNALERROR> E                 teardown.throw(exception)
INTERNALERROR> E               File "/usr/local/lib/python3.10/site-packages/_pytest/faulthandler.py", line 88, in pytest_runtest_protocol
INTERNALERROR> E                 return (yield)
INTERNALERROR> E               File "/usr/local/lib/python3.10/site-packages/pluggy/_callers.py", line 121, in _multicall
INTERNALERROR> E                 res = hook_impl.function(*args)
INTERNALERROR> E               File "/usr/local/lib/python3.10/site-packages/_pytest/runner.py", line 117, in pytest_runtest_protocol
INTERNALERROR> E                 runtestprotocol(item, nextitem=nextitem)
INTERNALERROR> E               File "/usr/local/lib/python3.10/site-packages/_pytest/runner.py", line 136, in runtestprotocol
INTERNALERROR> E                 reports.append(call_and_report(item, "call", log))
INTERNALERROR> E               File "/usr/local/lib/python3.10/site-packages/_pytest/runner.py", line 250, in call_and_report
INTERNALERROR> E                 ihook.pytest_runtest_logreport(report=report)
INTERNALERROR> E               File "/usr/local/lib/python3.10/site-packages/pluggy/_hooks.py", line 512, in __call__
INTERNALERROR> E                 return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
INTERNALERROR> E               File "/usr/local/lib/python3.10/site-packages/pluggy/_manager.py", line 120, in _hookexec
INTERNALERROR> E                 return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR> E               File "/usr/local/lib/python3.10/site-packages/pluggy/_callers.py", line 167, in _multicall
INTERNALERROR> E                 raise exception
INTERNALERROR> E               File "/usr/local/lib/python3.10/site-packages/pluggy/_callers.py", line 121, in _multicall
INTERNALERROR> E                 res = hook_impl.function(*args)
INTERNALERROR> E               File "/usr/local/lib/python3.10/site-packages/xdist/remote.py", line 289, in pytest_runtest_logreport
INTERNALERROR> E                 self.sendevent("testreport", data=data)
INTERNALERROR> E               File "/usr/local/lib/python3.10/site-packages/xdist/remote.py", line 126, in sendevent
INTERNALERROR> E                 self.channel.send((name, kwargs))
INTERNALERROR> E               File "/usr/local/lib/python3.10/site-packages/execnet/gateway_base.py", line 912, in send
INTERNALERROR> E                 self.gateway._send(Message.CHANNEL_DATA, self.id, dumps_internal(item))
INTERNALERROR> E               File "/usr/local/lib/python3.10/site-packages/execnet/gateway_base.py", line 1629, in dumps_internal
INTERNALERROR> E                 return _Serializer().save(obj)  # type: ignore[return-value]
INTERNALERROR> E               File "/usr/local/lib/python3.10/site-packages/execnet/gateway_base.py", line 1647, in save
INTERNALERROR> E                 self._save(obj)
INTERNALERROR> E               File "/usr/local/lib/python3.10/site-packages/execnet/gateway_base.py", line 1667, in _save
INTERNALERROR> E                 dispatch(self, obj)
INTERNALERROR> E               File "/usr/local/lib/python3.10/site-packages/execnet/gateway_base.py", line 1744, in save_tuple
INTERNALERROR> E                 self._save(item)
INTERNALERROR> E               File "/usr/local/lib/python3.10/site-packages/execnet/gateway_base.py", line 1667, in _save
INTERNALERROR> E                 dispatch(self, obj)
INTERNALERROR> E               File "/usr/local/lib/python3.10/site-packages/execnet/gateway_base.py", line 1740, in save_dict
INTERNALERROR> E                 self._write_setitem(key, value)
INTERNALERROR> E               File "/usr/local/lib/python3.10/site-packages/execnet/gateway_base.py", line 1734, in _write_setitem
INTERNALERROR> E                 self._save(value)
INTERNALERROR> E               File "/usr/local/lib/python3.10/site-packages/execnet/gateway_base.py", line 1667, in _save
INTERNALERROR> E                 dispatch(self, obj)
INTERNALERROR> E               File "/usr/local/lib/python3.10/site-packages/execnet/gateway_base.py", line 1740, in save_dict
INTERNALERROR> E                 self._write_setitem(key, value)
INTERNALERROR> E               File "/usr/local/lib/python3.10/site-packages/execnet/gateway_base.py", line 1734, in _write_setitem
INTERNALERROR> E                 self._save(value)
INTERNALERROR> E               File "/usr/local/lib/python3.10/site-packages/execnet/gateway_base.py", line 1665, in _save
INTERNALERROR> E                 raise DumpError(f"can't serialize {tp}") from None
INTERNALERROR> E             execnet.gateway_base.DumpError: can't serialize <class '_pytest._code.code.ExceptionInfo'>
INTERNALERROR> E           assert False
INTERNALERROR>
INTERNALERROR> /usr/local/lib/python3.10/site-packages/xdist/dsession.py:232: AssertionError
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/usr/local/lib/python3.10/site-packages/_pytest/main.py", line 289, in wrap_session
INTERNALERROR>     session.exitstatus = doit(config, session) or 0
INTERNALERROR>   File "/usr/local/lib/python3.10/site-packages/_pytest/main.py", line 343, in _main
INTERNALERROR>     config.hook.pytest_runtestloop(session=session)
INTERNALERROR>   File "/usr/local/lib/python3.10/site-packages/pluggy/_hooks.py", line 512, in __call__
INTERNALERROR>     return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
INTERNALERROR>   File "/usr/local/lib/python3.10/site-packages/pluggy/_manager.py", line 120, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR>   File "/usr/local/lib/python3.10/site-packages/pluggy/_callers.py", line 167, in _multicall
INTERNALERROR>     raise exception
INTERNALERROR>   File "/usr/local/lib/python3.10/site-packages/pluggy/_callers.py", line 139, in _multicall
INTERNALERROR>     teardown.throw(exception)
INTERNALERROR>   File "/usr/local/lib/python3.10/site-packages/_pytest/logging.py", line 801, in pytest_runtestloop
INTERNALERROR>     return (yield)  # Run all the tests.
INTERNALERROR>   File "/usr/local/lib/python3.10/site-packages/pluggy/_callers.py", line 139, in _multicall
INTERNALERROR>     teardown.throw(exception)
INTERNALERROR>   File "/usr/local/lib/python3.10/site-packages/_pytest/terminal.py", line 688, in pytest_runtestloop
INTERNALERROR>     result = yield
INTERNALERROR>   File "/usr/local/lib/python3.10/site-packages/pluggy/_callers.py", line 121, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/usr/local/lib/python3.10/site-packages/xdist/dsession.py", line 138, in pytest_runtestloop
INTERNALERROR>     self.loop_once()
INTERNALERROR>   File "/usr/local/lib/python3.10/site-packages/xdist/dsession.py", line 163, in loop_once
INTERNALERROR>     call(**kwargs)
INTERNALERROR>   File "/usr/local/lib/python3.10/site-packages/xdist/dsession.py", line 217, in worker_workerfinished
INTERNALERROR>     assert not crashitem, (crashitem, node)
INTERNALERROR> AssertionError: ('shared/secrets_masker/tests/secrets_masker/test_secrets_masker.py::TestSecretsMasker::test_property_for_log_masking', <WorkerController gw11>)
INTERNALERROR> assert not 'shared/secrets_masker/tests/secrets_masker/test_secrets_masker.py::TestSecretsMasker::test_property_for_log_masking'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions