Skip to content

Commit aa44e31

Browse files
dpark01claude
andcommitted
Fix MultiQC task to handle crashes from empty/invalid FastQC zip files
## Problem PR #606 attempted to fix MultiQC task failures when processing empty FastQC zip files, but the fix was incomplete. MultiQC crashes with exit code 1 when it encounters empty zip files, causing the WDL task to fail before reaching the error handling code. ### Root Cause MultiQC (both v1.8 and v1.32) crashes when processing empty zip archives: ``` IndexError: list index out of range at: d_name = fqc_zip.namelist()[0] ``` The previous fix added cleanup code but didn't handle the crash itself: 1. Command block starts with `set -e` (exit on any error) 2. MultiQC crashes with exit code 1 3. Script terminates immediately, never reaching cleanup code ## Solution Modified the MultiQC task command block to gracefully handle crashes: 1. **Wrap MultiQC call**: Use `set +e` before calling MultiQC to prevent immediate script termination on error 2. **Capture exit code**: Store MultiQC's exit code in `MULTIQC_EXIT_CODE` 3. **Re-enable error checking**: Use `set -e` after MultiQC completes 4. **Update Docker image**: Upgrade from v1.8 to v1.32 (latest stable) 5. **Improve error suppression**: Add `2>/dev/null || true` to mv command The existing safety nets (creating placeholder HTML and empty data directory) now execute successfully regardless of MultiQC's exit status. ## Testing Tested with empty FastQC zip file that previously caused task failure: - ✅ Task completes successfully (exit code 0) - ✅ Creates placeholder HTML: "No analysis results found in input files" - ✅ Creates empty data tarball - ✅ WDL syntax validates with miniwdl This fix ensures workflows don't fail when upstream tasks produce empty or corrupted FastQC outputs, which can occur with low-quality or no-read samples. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent ee094f0 commit aa44e31

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

pipes/WDL/tasks/tasks_reports.wdl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ task MultiQC {
643643
File? config # directory
644644
String? config_yaml
645645
646-
String docker = "quay.io/biocontainers/multiqc:1.8--py_2"
646+
String docker = "quay.io/biocontainers/multiqc:1.32--pyhdfd78af_1"
647647
}
648648
649649
parameter_meta {
@@ -660,6 +660,8 @@ task MultiQC {
660660
echo "${sep='\n' input_files}" > input-filenames.txt
661661
echo "" >> input-filenames.txt
662662
663+
# Run MultiQC but allow it to fail (it crashes with exit 1 on empty/invalid zip files)
664+
set +e
663665
multiqc \
664666
--file-list input-filenames.txt \
665667
--outdir "${out_dir}" \
@@ -687,15 +689,17 @@ task MultiQC {
687689
${false="--no-megaqc-upload" true="" megaQC_upload} \
688690
${"--config " + config} \
689691
${"--cl-config " + config_yaml }
692+
MULTIQC_EXIT_CODE=$?
693+
set -e
690694
691-
# Ensure output directory exists (MultiQC may remove it if no results found)
695+
# Ensure output directory exists (MultiQC may remove it if no results found or if it crashed)
692696
mkdir -p "${out_dir}"
693697
694698
if [ -z "${file_name}" ]; then
695-
mv "${out_dir}/${report_filename}_report.html" "${out_dir}/${report_filename}.html"
699+
mv "${out_dir}/${report_filename}_report.html" "${out_dir}/${report_filename}.html" 2>/dev/null || true
696700
fi
697701
698-
# Create placeholder HTML report if MultiQC didn't create one (happens when no valid results found)
702+
# Create placeholder HTML report if MultiQC didn't create one (happens when no valid results found or on crash)
699703
if [ ! -f "${out_dir}/${report_filename}.html" ]; then
700704
echo "<!DOCTYPE html><html><head><meta charset=\"UTF-8\"><title>MultiQC Report</title></head><body><h1>MultiQC Report</h1><p>No analysis results found in input files.</p></body></html>" > "${out_dir}/${report_filename}.html"
701705
fi

0 commit comments

Comments
 (0)