Join error An unexpected error occurred: a bytes-like object is required, not 'str'

The domain master (nothing wrong with masters!) upgraded just fine, no visible issues apart from the dark theme, which I find more of an eye strain. However, the domain journeymen (aka backup or secondary domain controllers) failed to execute three join scripts (20, 33 and 35) with the above Python error, leaving them dead in the water.

I ran univention-join from the command line afterwards and that seems to have done the job…

Confidence level still a bit low, but at least the diagnostics now show no issue.

I also set up a new BDC from scratch, which worked just fine without any join script errors.

So this error seems to occur only, when secondary domain controllers are updated in place via the GUI.

I have experienced the same behavior and also solved it by re-joining the BDC to the MDC domain via command line. The GUI was throwing the same subject error.

The GUI problem might be solved by patching /usr/lib/python3/dist-packages/notifier/threads.py at line 177 as follows:

-        with tempfile.NamedTemporaryFile() as passwordFile:
+        with tempfile.NamedTemporaryFile(mode='w+t') as passwordFile:

From what little I undertand from Python and the v2/v3 transition, that looks very reasonable.

I’m even tempted to try it (but short of time to really do so), but even more surprised it didn’t come up during testing, since it’s really a very basic operation on an upgrade on the simplest setup.

And I don’t quite understand how it behaves differently when running the script via the GUI and manually: I thought the transition from Python 2 to 3 was 100%

The rest of the upgrade was super smooth (well getting rid of KDE took a bit of time) and really impressive when I compare that to my CentOS7-oVirt 4.3/CentOS8-oVirt 4.4 experience.

I got a suggestion by email that other places in the same file solved it like this:

-               passwordFile.write(password)
+               passwordFile.write(password.encode('UTF-8'))

either should work (but not both at the same time). My previous suggestion might need to add encoding='UTF-8' additionally to the mode option.

The error is not in the actual join script, but in the “web interface glue” that (tries to) run(s) the script when one clicks on the button on the web UI. So running the script directly from the command line totally bypasses that.

thanks Imamane, for following up!

Sounds right, both would seem to solve the issue that Python 3 assumes Unicode by default, while earlier variants were still more ASCIIsh.

And I guess GUI glue is still more difficult to put into test automation tools than straight forward scripts…

I’ve found the Univention Github/Bugzilla so I guess I can post an error report there. I’ll be sure to mention your name, when and if I do (of course, I’d let you go first, since you found the bug and proposed a solution…)

Can you please attach the full traceback?
It should be in /var/log/univention/management-console-module-join.log or in /var/log/univention/management-console-web-server.log.
Thanks!

We will fix this within https://forge.univention.org/bugzilla/show_bug.cgi?id=53181

MODULE      ( WARN    ) : Exception during running join scripts:   File "/usr/lib/python3/dist-packages/notifier/threads.py", line 80, in _run
    result = self._function()
  File "/usr/lib/python3/dist-packages/univention/management/console/modules/join/__init__.py", line 483, in _thread
    critical_handler=self.progress_state.critical_handler,
  File "/usr/lib/python3/dist-packages/univention/management/console/modules/join/__init__.py", line 181, in run_join_scripts
    passwordFile.write(password)
  File "/usr/lib/python3.7/tempfile.py", line 620, in func_wrapper
    return func(*args, **kwargs)
TypeError: a bytes-like object is required, not 'str'
1 Like
Mastodon