galaxy icon indicating copy to clipboard operation
galaxy copied to clipboard

Expression tool input wrapping can fail with None values

Open mvdbeek opened this issue 2 years ago • 2 comments

TypeError: 'NoneType' object does not support item assignment
  File "galaxy/jobs/runners/__init__.py", line 297, in prepare_job
    job_wrapper.prepare()
  File "galaxy/jobs/__init__.py", line 1249, in prepare
    tool_evaluator.set_compute_environment(compute_environment, get_special=get_special)
  File "galaxy/tools/evaluation.py", line 171, in set_compute_environment
    self.execute_tool_hooks(inp_data=inp_data, out_data=out_data, incoming=incoming)
  File "galaxy/tools/evaluation.py", line 176, in execute_tool_hooks
    self.tool.exec_before_job(self.app, inp_data, out_data, self.param_dict)
  File "galaxy/tools/__init__.py", line 2849, in exec_before_job
    json_wrap(self.inputs, param_dict, self.profile, job, handle_files="OBJECT")
  File "galaxy/tools/parameters/wrapped_json.py", line 31, in json_wrap
    json_value = _json_wrap_input(input, value_wrapper, profile, handle_files=handle_files)
  File "galaxy/tools/parameters/wrapped_json.py", line 141, in _json_wrap_input
    json_value["contents"] = fh.read(input.load_contents).decode("utf-8", errors="replace")

from https://sentry.galaxyproject.org/share/issue/021c4d3c646149eab718d9ceea5487ea/.

json_value here is None, which I think is a valid input, but it looks like a this was part of a workflow that failed early on, including a proper workflow invocation error message, so this might not be a high-priority bug.

mvdbeek avatar Apr 11 '24 09:04 mvdbeek

The tool in question is param_value_from_file

mvdbeek avatar Apr 11 '24 09:04 mvdbeek

I investigated a bit this issue, but I need some hints.

If we allow json_value to be None, what would be the expected output in param_value_from_file?:

https://github.com/galaxyproject/galaxy/blob/f98f6f794e6a025011bc29ba0fd4b10023676751/tools/expression_tools/parse_values_from_file.xml#L30

Would this be the desired output?:

{"output": null}

If that is the case, this leads to a different error down the road:

galaxy.tool_util.output_checker INFO 2024-04-19 18:07:59,295 [pN:main.1,p:583932,tN:LocalRunner.work_thread-1] Job failed because of contents in the standard error stream: [Traceback (most recent call last):
  File "/home/dlopez/sandbox/data-gx/24.0/jobs_directory/000/416/_evaluate_expression_.py", line 1, in <module>
    from galaxy_ext.expressions.handle_job import run; run()
                                                       ^^^^^
  File "/home/dlopez/dev/gx-version/24.0/lib/galaxy_ext/expressions/handle_job.py", line 54, in run
    output_value = expression.interpolate(from_expression, result)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dlopez/dev/gx-version/24.0/.venv/lib/python3.11/site-packages/cwl_utils/expression.py", line 215, in interpolate
    e = evaluator(
        ^^^^^^^^^^
  File "/home/dlopez/dev/gx-version/24.0/.venv/lib/python3.11/site-packages/cwl_utils/expression.py", line 164, in evaluator
    raise JavascriptException(
cwl_utils.errors.JavascriptException: Syntax error in parameter reference 'output': output is not defined. This could be due to using Javascript code without specifying InlineJavascriptRequirement.
]
galaxy.jobs DEBUG 2024-04-19 18:07:59,337 [pN:main.1,p:583932,tN:LocalRunner.work_thread-1] (416) setting dataset 417 state to ERROR

So I guess we need to return something else as output, right? :thinking:

davelopez avatar Apr 19 '24 16:04 davelopez