diff --git a/lib/galaxy/jobs/__init__.py b/lib/galaxy/jobs/__init__.py index 084f0e9d62ec..0d7c9572af17 100644 --- a/lib/galaxy/jobs/__init__.py +++ b/lib/galaxy/jobs/__init__.py @@ -1786,13 +1786,14 @@ def _finish_dataset(self, output_name, dataset, job, context, final_job_state, r working_directory=self.working_directory, remote_metadata_directory=remote_metadata_directory, ) - line_count = context.get("line_count", None) - try: - # Certain datatype's set_peek methods contain a line_count argument - dataset.set_peek(line_count=line_count) - except TypeError: - # ... and others don't - dataset.set_peek() + if final_job_state != job.states.ERROR: + line_count = context.get("line_count", None) + try: + # Certain datatype's set_peek methods contain a line_count argument + dataset.set_peek(line_count=line_count) + except TypeError: + # ... and others don't + dataset.set_peek() else: # Handle purged datasets. dataset.blurb = "empty"