# Buggy code
def env_vars_as_dict(self, logger: Optional[object] = None) -> Dict:
    """Operation stores environment variables in a list of name=value pairs, while
    subprocess.run() requires a dictionary - so we must convert.  If no envs are
    configured on the Operation, the existing env is returned, otherwise envs
    configured on the Operation are overlayed on the existing env.
    """
    envs = os.environ.copy()
    for nv in self.env_vars:
        if len(nv) > 0:
            nv_pair = nv.split("=")
            if len(nv_pair) == 2:
                envs[nv_pair[0]] = nv_pair[1]
            else:
                if logger:
                    logger.warning(
                        f"Could not process environment variable entry `{nv}`, skipping..."
                    )
                else:
                    print(
                        f"Could not process environment variable entry `{nv}`, skipping..."
                    )
    return envs


# Traceback (subprocess.CalledProcessError)
Traceback (most recent call last):
File "/opt/conda/lib/python3.7/site-packages/elyra/pipeline/processor_local.py", line 151, in process
subprocess.run(argv, cwd=file_dir, env=envs, check=True)
File "/opt/conda/lib/python3.7/subprocess.py", line 512, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['papermill', '/home/jovyan/work/Untitled.ipynb', '/home/jovyan/work/Untitled.ipynb', '--cwd', '/home/jovyan/work']' returned non-zero exit status 1.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/opt/conda/lib/python3.7/site-packages/elyra/pipeline/processor_local.py", line 70, in process
operation_processor.process(operation)
File "/opt/conda/lib/python3.7/site-packages/elyra/pipeline/processor_local.py", line 154, in process
raise RuntimeError(f'Internal error executing {filepath}') from ex
RuntimeError: Internal error executing /home/jovyan/work/Untitled.ipynb

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/opt/conda/lib/python3.7/site-packages/tornado/web.py", line 1703, in _execute
result = await result
File "/opt/conda/lib/python3.7/site-packages/elyra/pipeline/handlers.py", line 89, in post
response = await PipelineProcessorManager.instance().process(pipeline)
File "/opt/conda/lib/python3.7/site-packages/elyra/pipeline/processor.py", line 69, in process
res = await asyncio.get_event_loop().run_in_executor(None, processor.process, pipeline)
File "/opt/conda/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/opt/conda/lib/python3.7/site-packages/elyra/pipeline/processor_local.py", line 72, in process
raise RuntimeError(f'Error processing operation {operation.name}.') from ex
RuntimeError: Error processing operation Untitled.

# Fixed code
def env_vars_as_dict(self, logger: Optional[object] = None) -> Dict:
    """Operation stores environment variables in a list of name=value pairs, while
    subprocess.run() requires a dictionary - so we must convert.  If no envs are
    configured on the Operation, the existing env is returned, otherwise envs
    configured on the Operation are overlayed on the existing env.
    """
    envs = {}
    for nv in self.env_vars:
        if len(nv) > 0:
            nv_pair = nv.split("=")
            if len(nv_pair) == 2:
                envs[nv_pair[0]] = nv_pair[1]
            else:
                if logger:
                    logger.warning(
                        f"Could not process environment variable entry `{nv}`, skipping..."
                    )
                else:
                    print(
                        f"Could not process environment variable entry `{nv}`, skipping..."
                    )
    return envs