OpenJobDescription / openjd-adaptor-runtime-for-python

A python library for building adaptors that integrate applications with Open Job Description jobs
Apache License 2.0
11 stars 9 forks source link

Bug: UTF-16 Strings are not handled properly #160

Open yuanmich2 opened 1 week ago

yuanmich2 commented 1 week ago

Describe the bug

When the stdout of a program is in UTF-16, the app handler interprets the string as UTF-8 but with null characters (\x00) between each character.

This makes writing regex patterns for the regex handlers difficult because you need to account for all the null characters.

Expected Behaviour

UTF-16 strings should be properly parsed so there are no null characters

Current Behaviour

The app handler puts \x00 between each character

Reproduction Steps

The 3ds Max Adaptor (https://github.com/aws-deadline/deadline-cloud-for-3ds-max) can be modified to use 3dsmaxbatch by changing the call command in adaptor.py to this:

args=["3dsmaxbatch", "-dm", "on", "-v", "5", self.max_client_path],

After doing so, all the regex patterns used by the regex handlers will fail because they don't account for null characters. Regex patterns can be found here: https://github.com/aws-deadline/deadline-cloud-for-3ds-max/blob/59d1716000dda7fbf41a3b81888ded550f04a780/src/deadline/max_adaptor/MaxAdaptor/adaptor.py#L173-L175

Environment

At minimum:

  1. Operating system: Windows Server 2025
  2. Output of python3 --version: 3.10
  3. Version of this library. 0.8.1

Please share other details about your environment that you think might be relevant to reproducing the bug. I first encountered the bug while trying to build a 3ds max batch CMF worker

AWS-Samuel commented 2 days ago

The LoggingSubprocess does make available an optional encoding argument that allows consumers to specify the output encoding of a given application. I think if you add encoding="utf-16" in the 3dsMaxAdaptor when creating the LoggingSubprocess for 3dsMax here: https://github.com/aws-deadline/deadline-cloud-for-3ds-max/blob/59d1716000dda7fbf41a3b81888ded550f04a780/src/deadline/max_adaptor/MaxAdaptor/adaptor.py#L268C13-L268C41 then you may have success with the regex patterns which weren't previously working.

Please let me know if this works for you!