diff --git a/samtools.wdl b/samtools.wdl
index 0c3b589768c001040dfd3a218b450163944f9aeb..da7d57026b07ba01a2e7fd29bc36f97c3fcb8ac8 100644
--- a/samtools.wdl
+++ b/samtools.wdl
@@ -31,10 +31,12 @@ task BgzipAndIndex {
 task Index {
     input {
         File bamFile
-        String? outputBamPath
+        String outputBamPath = basename(bamFile)
         String dockerImage = "quay.io/biocontainers/samtools:1.8--h46bd0b3_5"
     }
-    String bamIndexPath = sub(select_first([outputBamPath, basename(bamFile)]), "\.bam$", ".bai")
+
+    # Select_first is needed, otherwise womtool validate fails.
+    String bamIndexPath = sub(select_first([outputBamPath]), "\.bam$", ".bai")
 
     command {
         bash -c '