# Buggy code
def add_output(self, workflow_output, step, output_object):
    if output_object.history_content_type == "dataset":
        output_assoc = WorkflowInvocationOutputDatasetAssociation()
        output_assoc.workflow_invocation = self
        output_assoc.workflow_output = workflow_output
        output_assoc.workflow_step = step
        output_assoc.dataset = output_object
        self.output_datasets.append(output_assoc)
    elif output_object.history_content_type == "dataset_collection":
        output_assoc = WorkflowInvocationOutputDatasetCollectionAssociation()
        output_assoc.workflow_invocation = self
        output_assoc.workflow_output = workflow_output
        output_assoc.workflow_step = step
        output_assoc.dataset_collection = output_object
        self.output_dataset_collections.append(output_assoc)
    else:
        raise Exception("Unknown output type encountered")


# Traceback (AttributeError)
galaxy.workflow.scheduling_manager DEBUG 2019-01-23 23:20:06,529 [p:6571,w:0,m:3] [WorkflowRequestMonitor.monitor_thread] Attempting to schedule workflow invocation [(808,)]
galaxy.workflow.run ERROR 2019-01-23 23:20:06,736 [p:6571,w:0,m:3] [WorkflowRequestMonitor.monitor_thread] Failed to schedule Workflow[id=879,name=findcluster complete], problem occurred on WorkflowStep[index=0,type=parameter_input].
Traceback (most recent call last):
File "lib/galaxy/workflow/run.py", line 190, in invoke
incomplete_or_none = self._invoke_step(workflow_invocation_step)
File "lib/galaxy/workflow/run.py", line 266, in _invoke_step
use_cached_job=self.workflow_invocation.use_cached_job)
File "lib/galaxy/workflow/modules.py", line 702, in execute
progress.set_outputs_for_input(invocation_step, step_outputs)
File "lib/galaxy/workflow/run.py", line 397, in set_outputs_for_input
self.set_step_outputs(invocation_step, outputs)
File "lib/galaxy/workflow/run.py", line 428, in set_step_outputs
output=output,
File "lib/galaxy/workflow/run.py", line 432, in _record_workflow_output
self.workflow_invocation.add_output(workflow_output, step, output)
File "lib/galaxy/model/__init__.py", line 4444, in add_output
if output_object.history_content_type == "dataset":
AttributeError: 'unicode' object has no attribute 'history_content_type'
galaxy.workflow.run ERROR 2019-01-23 23:20:06,736 [p:6571,w:0,m:3] [WorkflowRequestMonitor.monitor_thread] Failed to execute scheduled workflow.
Traceback (most recent call last):
File "lib/galaxy/workflow/run.py", line 83, in __invoke
outputs = invoker.invoke()
File "lib/galaxy/workflow/run.py", line 190, in invoke
incomplete_or_none = self._invoke_step(workflow_invocation_step)
File "lib/galaxy/workflow/run.py", line 266, in _invoke_step
use_cached_job=self.workflow_invocation.use_cached_job)
File "lib/galaxy/workflow/modules.py", line 702, in execute
progress.set_outputs_for_input(invocation_step, step_outputs)
File "lib/galaxy/workflow/run.py", line 397, in set_outputs_for_input
self.set_step_outputs(invocation_step, outputs)
File "lib/galaxy/workflow/run.py", line 428, in set_step_outputs
output=output,
File "lib/galaxy/workflow/run.py", line 432, in _record_workflow_output
self.workflow_invocation.add_output(workflow_output, step, output)
File "lib/galaxy/model/__init__.py", line 4444, in add_output
if output_object.history_content_type == "dataset":
AttributeError: 'unicode' object has no attribute 'history_content_type'

# Fixed code
def add_output(self, workflow_output, step, output_object):
    if step.type == "parameter_input":
        # TODO: these should be properly tracked.
        return
    if output_object.history_content_type == "dataset":
        output_assoc = WorkflowInvocationOutputDatasetAssociation()
        output_assoc.workflow_invocation = self
        output_assoc.workflow_output = workflow_output
        output_assoc.workflow_step = step
        output_assoc.dataset = output_object
        self.output_datasets.append(output_assoc)
    elif output_object.history_content_type == "dataset_collection":
        output_assoc = WorkflowInvocationOutputDatasetCollectionAssociation()
        output_assoc.workflow_invocation = self
        output_assoc.workflow_output = workflow_output
        output_assoc.workflow_step = step
        output_assoc.dataset_collection = output_object
        self.output_dataset_collections.append(output_assoc)
    else:
        raise Exception("Unknown output type encountered")