Raise a clear error for an empty command line (#1618)#2287
Open
arimu1 wants to merge 1 commit into
Open
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Fixes #1618.
A
CommandLineToolwith nobaseCommand,arguments, or input bindings produces an empty command line. cwltool passed that empty list straight tosubprocess.Popen([]), which crashes with a raw, confusing error:…originating deep inside
subprocess(executable = args[0]), rather than a clean validation error for the malformed-but-parseable document.Repro
Fix
Guard the empty-command case in
JobBase._execute(cwltool/job.py) right after the command list is constructed, and raise aWorkflowExceptionwith an actionable message: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 (whereruntimesuppliesdocker run <image>) is unaffected, so relying on an image's defaultCMDstill works. The existingexcept WorkflowExceptionhandler turns this into a cleanpermanentFailinstead of an unhandled traceback.Tests
Added
tests/wf/no-basecommand.cwlfixture andtest_empty_command_line_errorintests/test_examples.py, asserting a non-zero exit, the new message in stderr, and noIndexError.Verified
black,flake8, andisortare 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.