diff --git a/pydra/engine/task.py b/pydra/engine/task.py
index 8cb088a2..d8aaa60d 100644
--- a/pydra/engine/task.py
+++ b/pydra/engine/task.py
@@ -199,19 +199,21 @@ class FunctionTask(TaskBase):
         del inputs["_func"]
         self.output_ = None
         output = cp.loads(self.inputs._func)(**inputs)
-        if output is not None:
-            output_names = [el[0] for el in self.output_spec.fields]
-            self.output_ = {}
-            if len(output_names) > 1:
-                if len(output_names) == len(output):
+        output_names = [el[0] for el in self.output_spec.fields]
+        if output is None:
+            self.output_ = dict((nm, None) for nm in output_names)
+        else:
+            if len(output_names) == 1:
+                # if only one element in the fields, everything should be returned together
+                self.output_ = {output_names[0]: output}
+            else:
+                if isinstance(output, tuple) and len(output_names) == len(output):
                     self.output_ = dict(zip(output_names, output))
                 else:
                     raise Exception(
                         f"expected {len(self.output_spec.fields)} elements, "
-                        f"but {len(output)} were returned"
+                        f"but {output} were returned"
                     )
-            else:  # if only one element in the fields, everything should be returned together
-                self.output_[output_names[0]] = output
 
 
 class ShellCommandTask(TaskBase):

Task crashes when function returns None
in both cases the named outputs should be set to `None`.

```
import pydra
import typing as ty
import os


@pydra.mark.task
@pydra.mark.annotate({"return": {"b": ty.Any}})
def test_multiout(val, val2):
    return None


if __name__ == "__main__":
    cache_dir = os.path.join(os.getcwd(), 'cache3')
    task = test_multiout(name="mo2",
                         val=[0, 1, 2],
                         val2=[4, 5, 6],
                         cache_dir=cache_dir)
    with pydra.Submitter(plugin="cf", n_procs=2) as sub:
        sub(runnable=task)
    results = task.result()
    print(results)
```

this should also be checked for multiple outputs.

```
@pydra.mark.task
@pydra.mark.annotate({"return": {"a": ty.Any, "b": ty.Any}})
def test_multiout(val, val2):
    return None

```
diff --git a/pydra/engine/tests/test_task.py b/pydra/engine/tests/test_task.py
index f7f4182e..eaa21f99 100644
--- a/pydra/engine/tests/test_task.py
+++ b/pydra/engine/tests/test_task.py
@@ -309,6 +309,31 @@ def test_exception_func():
     assert pytest.raises(Exception, bad_funk)
 
 
+def test_result_none_1():
+    """ checking if None is properly returned as the result"""
+
+    @mark.task
+    def fun_none(x):
+        return None
+
+    task = fun_none(name="none", x=3)
+    res = task()
+    assert res.output.out is None
+
+
+def test_result_none_2():
+    """ checking if None is properly set for all outputs """
+
+    @mark.task
+    def fun_none(x) -> (ty.Any, ty.Any):
+        return None
+
+    task = fun_none(name="none", x=3)
+    res = task()
+    assert res.output.out1 is None
+    assert res.output.out2 is None
+
+
 def test_audit_prov(tmpdir):
     @mark.task
     def testfunc(a: int, b: float = 0.1) -> ty.NamedTuple("Output", [("out", float)]):

pip install -e .[dev]
parse_log_pytest
requirements.txt
pytest pytest-cov flake8
3.9
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
asttokens==3.0.0
attrs==25.3.0
beautifulsoup4==4.13.3
black==25.1.0
bleach==6.2.0
boutiques==0.5.28
cachetools==5.5.2
certifi==2025.1.31
cfgv==3.4.0
charset-normalizer==3.4.1
ci-info==0.3.0
click==8.1.8
cloudpickle==3.1.1
codecov==2.1.13
comm==0.2.2
coverage==7.8.0
debugpy==1.8.13
decorator==5.2.1
defusedxml==0.7.1
distlib==0.3.9
entrypoints==0.4
etelemetry==0.3.1
exceptiongroup==1.2.2
execnet==2.1.1
executing==2.2.0
fastjsonschema==2.21.1
filelock==3.18.0
flake8==7.2.0
frozendict==2.4.6
identify==2.6.9
idna==3.10
importlib_metadata==8.6.1
iniconfig==2.1.0
ipykernel==6.9.2
ipython==8.18.1
ipython-genutils==0.2.0
ipywidgets==8.1.5
jedi==0.19.2
Jinja2==3.1.6
json5==0.10.0
jsonschema==4.23.0
jsonschema-specifications==2024.10.1
jupyter==1.1.1
jupyter-client==7.1.2
jupyter-console==6.4.4
jupyter-contrib-nbextensions==0.5.1
jupyter-highlight-selected-word==0.2.0
jupyter_contrib_core==0.4.2
jupyter_core==5.7.2
jupyter_latex_envs==1.4.6
jupyter_nbextensions_configurator==0.4.1
jupyterlab==2.3.2
jupyterlab-server==1.2.0
jupyterlab_pygments==0.3.0
jupyterlab_widgets==3.0.13
lxml==5.3.1
MarkupSafe==3.0.2
matplotlib-inline==0.1.7
mccabe==0.7.0
mistune==3.1.3
mypy-extensions==1.0.0
nbclient==0.10.2
nbconvert==7.16.6
nbformat==5.10.4
nest-asyncio==1.6.0
nodeenv==1.9.1
notebook==5.7.8
numpy==2.0.2
packaging==24.2
pandocfilters==1.5.1
parso==0.8.4
pathspec==0.12.1
pexpect==4.9.0
platformdirs==4.3.7
pluggy==1.5.0
pre_commit==4.2.0
prometheus_client==0.21.1
prompt_toolkit==3.0.50
psutil==7.0.0
ptyprocess==0.7.0
pure_eval==0.2.3
pycodestyle==2.13.0
-e git+https://github.com/nipype/pydra.git@0067eeee42a8db39a80653e3821056c6ad87ead2#egg=pydra
pyflakes==3.3.1
Pygments==2.19.1
PyLD==2.0.4
pytest==8.3.5
pytest-cov==6.0.0
pytest-env==1.1.5
pytest-rerunfailures==15.0
pytest-xdist==3.6.1
python-dateutil==2.9.0.post0
PyYAML==6.0.2
pyzmq==26.3.0
referencing==0.36.2
requests==2.32.3
rpds-py==0.24.0
Send2Trash==1.8.3
simplejson==3.20.1
six==1.17.0
soupsieve==2.6
stack-data==0.6.3
tabulate==0.9.0
termcolor==2.5.0
terminado==0.13.3
tinycss2==1.4.0
tomli==2.2.1
tornado==4.5.3
traitlets==5.14.3
typing_extensions==4.13.0
urllib3==2.3.0
virtualenv==20.29.3
wcwidth==0.2.13
webencodings==0.5.1
widgetsnbextension==4.0.13
zipp==3.21.0

name: pydra
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - pip=25.0=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - asttokens==3.0.0
      - attrs==25.3.0
      - beautifulsoup4==4.13.3
      - black==25.1.0
      - bleach==6.2.0
      - boutiques==0.5.28
      - cachetools==5.5.2
      - certifi==2025.1.31
      - cfgv==3.4.0
      - charset-normalizer==3.4.1
      - ci-info==0.3.0
      - click==8.1.8
      - cloudpickle==3.1.1
      - codecov==2.1.13
      - comm==0.2.2
      - coverage==7.8.0
      - debugpy==1.8.13
      - decorator==5.2.1
      - defusedxml==0.7.1
      - distlib==0.3.9
      - entrypoints==0.4
      - etelemetry==0.3.1
      - exceptiongroup==1.2.2
      - execnet==2.1.1
      - executing==2.2.0
      - fastjsonschema==2.21.1
      - filelock==3.18.0
      - flake8==7.2.0
      - frozendict==2.4.6
      - identify==2.6.9
      - idna==3.10
      - importlib-metadata==8.6.1
      - iniconfig==2.1.0
      - ipykernel==6.9.2
      - ipython==8.18.1
      - ipython-genutils==0.2.0
      - ipywidgets==8.1.5
      - jedi==0.19.2
      - jinja2==3.1.6
      - json5==0.10.0
      - jsonschema==4.23.0
      - jsonschema-specifications==2024.10.1
      - jupyter==1.1.1
      - jupyter-client==7.1.2
      - jupyter-console==6.4.4
      - jupyter-contrib-core==0.4.2
      - jupyter-contrib-nbextensions==0.5.1
      - jupyter-core==5.7.2
      - jupyter-highlight-selected-word==0.2.0
      - jupyter-latex-envs==1.4.6
      - jupyter-nbextensions-configurator==0.4.1
      - jupyterlab==2.3.2
      - jupyterlab-pygments==0.3.0
      - jupyterlab-server==1.2.0
      - jupyterlab-widgets==3.0.13
      - lxml==5.3.1
      - markupsafe==3.0.2
      - matplotlib-inline==0.1.7
      - mccabe==0.7.0
      - mistune==3.1.3
      - mypy-extensions==1.0.0
      - nbclient==0.10.2
      - nbconvert==7.16.6
      - nbformat==5.10.4
      - nest-asyncio==1.6.0
      - nodeenv==1.9.1
      - notebook==5.7.8
      - numpy==2.0.2
      - packaging==24.2
      - pandocfilters==1.5.1
      - parso==0.8.4
      - pathspec==0.12.1
      - pexpect==4.9.0
      - platformdirs==4.3.7
      - pluggy==1.5.0
      - pre-commit==4.2.0
      - prometheus-client==0.21.1
      - prompt-toolkit==3.0.50
      - psutil==7.0.0
      - ptyprocess==0.7.0
      - pure-eval==0.2.3
      - pycodestyle==2.13.0
      - pydra==0.5+14.g0067eeee
      - pyflakes==3.3.1
      - pygments==2.19.1
      - pyld==2.0.4
      - pytest==8.3.5
      - pytest-cov==6.0.0
      - pytest-env==1.1.5
      - pytest-rerunfailures==15.0
      - pytest-xdist==3.6.1
      - python-dateutil==2.9.0.post0
      - pyyaml==6.0.2
      - pyzmq==26.3.0
      - referencing==0.36.2
      - requests==2.32.3
      - rpds-py==0.24.0
      - send2trash==1.8.3
      - simplejson==3.20.1
      - six==1.17.0
      - soupsieve==2.6
      - stack-data==0.6.3
      - tabulate==0.9.0
      - termcolor==2.5.0
      - terminado==0.13.3
      - tinycss2==1.4.0
      - tomli==2.2.1
      - tornado==4.5.3
      - traitlets==5.14.3
      - typing-extensions==4.13.0
      - urllib3==2.3.0
      - virtualenv==20.29.3
      - wcwidth==0.2.13
      - webencodings==0.5.1
      - widgetsnbextension==4.0.13
      - zipp==3.21.0
prefix: /opt/conda/envs/pydra

pydra/engine/tests/test_task.py::test_result_none_1 pydra/engine/tests/test_task.py::test_result_none_2
pydra/engine/tests/test_task.py::test_output pydra/engine/tests/test_task.py::test_numpy pydra/engine/tests/test_task.py::test_annotated_func pydra/engine/tests/test_task.py::test_annotated_func_multreturn pydra/engine/tests/test_task.py::test_annotated_func_multreturn_exception pydra/engine/tests/test_task.py::test_halfannotated_func pydra/engine/tests/test_task.py::test_halfannotated_func_multreturn pydra/engine/tests/test_task.py::test_notannotated_func pydra/engine/tests/test_task.py::test_notannotated_func_returnlist pydra/engine/tests/test_task.py::test_halfannotated_func_multrun_returnlist pydra/engine/tests/test_task.py::test_notannotated_func_multreturn pydra/engine/tests/test_task.py::test_exception_func pydra/engine/tests/test_task.py::test_audit_prov pydra/engine/tests/test_task.py::test_audit_all pydra/engine/tests/test_task.py::test_shell_cmd pydra/engine/tests/test_task.py::test_container_cmds pydra/engine/tests/test_task.py::test_docker_cmd pydra/engine/tests/test_task.py::test_singularity_cmd pydra/engine/tests/test_task.py::test_functask_callable pydra/engine/tests/test_task.py::test_taskhooks
pydra/engine/task.py
pydra/engine/task.py