Skip to content

Raise a clear error for an empty command line (#1618)#2287

Open
arimu1 wants to merge 1 commit into
common-workflow-language:mainfrom
arimu1:fix/1618-empty-command-clear-error
Open

Raise a clear error for an empty command line (#1618)#2287
arimu1 wants to merge 1 commit into
common-workflow-language:mainfrom
arimu1:fix/1618-empty-command-clear-error

Conversation

@arimu1

@arimu1 arimu1 commented Jun 18, 2026

Copy link
Copy Markdown

Problem

Fixes #1618.

A CommandLineTool with no baseCommand, arguments, or input bindings produces an empty command line. cwltool passed that empty list straight to subprocess.Popen([]), which crashes with a raw, confusing error:

IndexError: list index out of range

…originating deep inside subprocess (executable = args[0]), rather than a clean validation error for the malformed-but-parseable document.

Repro

cwlVersion: v1.2
class: CommandLineTool
inputs: []
outputs: []
$ cwltool missing.cwl --debug
...
IndexError: list index out of range

Fix

Guard the empty-command case in JobBase._execute (cwltool/job.py) right after the command list is constructed, and raise a WorkflowException with an actionable message:

Cannot run a CommandLineTool that produces an empty command line. Specify a
'baseCommand', 'arguments', and/or an input with an 'inputBinding' so there is
a program to execute.

The condition is if not commands:, so it only fires when there is genuinely nothing to execute — i.e. no container runtime wrapper (docker run …) and no command. A container job (where runtime supplies docker run <image>) is unaffected, so relying on an image's default CMD still works. The existing except WorkflowException handler turns this into a clean permanentFail instead of an unhandled traceback.

Tests

Added tests/wf/no-basecommand.cwl fixture and test_empty_command_line_error in tests/test_examples.py, asserting a non-zero exit, the new message in stderr, and no IndexError.

$ python -m pytest tests/test_examples.py::test_empty_command_line_error -q
1 passed

Verified black, flake8, and isort are clean on the changed files, and that a normal tool (tests/echo.cwl) still runs.


This change was produced with the assistance of Claude Code (model: Claude Opus). The diff, root-cause analysis, and test were reviewed by a human before submission.

…ge#1618)

A CommandLineTool with no baseCommand, arguments, or input bindings
produces an empty command list. This was passed straight to
subprocess.Popen([]), which crashed with a raw
"IndexError: list index out of range" deep inside subprocess.

Guard the empty case in JobBase._execute and raise a WorkflowException
with an actionable message instead. The existing handler turns this
into a clean permanentFail rather than an unhandled traceback.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CommandLineTool without baseCommand → IndexError

1 participant