Skip to content

Commit

Permalink
Open tool file contents in rb
Browse files Browse the repository at this point in the history
Fixes
https://sentry.galaxyproject.org/share/issue/7e108c13d6634c20bc885e3ec4a93ce8/:

```
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8a in position 10: invalid start byte
  File "pulsar/managers/stateful.py", line 132, in _handling_of_preprocessing_state
    self._proxied_manager.launch(
  File "pulsar/managers/queued_drmaa.py", line 15, in launch
    self._check_execution_with_tool_file(job_id, command_line)
  File "pulsar/managers/base/directory.py", line 133, in _check_execution_with_tool_file
    self._check_execution(job_id, tool_id, command_line)
  File "pulsar/managers/base/__init__.py", line 189, in _check_execution
    contents = open(join(tool_files_dir, file)).read()
  File "<frozen codecs>", line 322, in decode
```
which is attempting to read PEHistogram.jar
  • Loading branch information
mvdbeek committed Sep 12, 2024
1 parent e726e5a commit 4258fd6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pulsar/managers/base/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def _check_execution(self, job_id, tool_id, command_line):
for file in self._list_dir(tool_files_dir):
if os.path.isdir(join(tool_files_dir, file)):
continue
contents = open(join(tool_files_dir, file)).read()
contents = open(join(tool_files_dir, file), "rb").read()
log.debug("job_id: {} - checking tool file {}".format(job_id, file))
authorization.authorize_tool_file(basename(file), contents)
config_files_dir = job_directory.configs_directory()
Expand Down
2 changes: 1 addition & 1 deletion pulsar/tools/authorization.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def authorize_tool_file(self, name, contents):
tool = self.tool
tool_dir = tool.get_tool_dir()
tool_dir_file = join(tool_dir, name)
allowed_contents = open(tool_dir_file).read()
allowed_contents = open(tool_dir_file, "rb").read()
if contents != allowed_contents:
self.__unauthorized("Attempt to write tool file with contents differing from Pulsar copy of tool file.")

Expand Down

0 comments on commit 4258fd6

Please sign in to comment.