Skip to content

Warn when 'baseCommand' is a single string with whitespace (#2240)#2292

Open
arimu1 wants to merge 1 commit into
common-workflow-language:mainfrom
arimu1:fix/2240-warn-basecommand-space
Open

Warn when 'baseCommand' is a single string with whitespace (#2240)#2292
arimu1 wants to merge 1 commit into
common-workflow-language:mainfrom
arimu1:fix/2240-warn-basecommand-space

Conversation

@arimu1

@arimu1 arimu1 commented Jun 19, 2026

Copy link
Copy Markdown

Problem

Addresses item 1 of #2240.

A CommandLineTool baseCommand written as a single string with internal whitespace — e.g.

baseCommand: "tar xf"

— is interpreted by CWL as one program name (argv[0] == "tar xf"), not as tar plus the argument xf. Such an executable almost never exists, so the tool fails at run time. Today --validate accepts this silently:

$ cwltool --validate space-basecommand.cwl
... space-basecommand.cwl is valid CWL.

The author almost certainly meant the list form [tar, xf].

Fix

Emit a warning at construction time (so it surfaces under --validate, before any execution) when baseCommand is a single string that splits into more than one whitespace-separated token. The warning points at the baseCommand source line and suggests the list form:

$ cwltool --validate space-basecommand.cwl
WARNING space-basecommand.cwl:4:1: 'baseCommand' is a single string containing
whitespace: 'tar xf'. It will be passed to the operating system as one program
name, which is unlikely to exist. If you meant a program plus arguments, provide
a list instead, e.g. ['tar', 'xf'].
... space-basecommand.cwl is valid CWL.

It is a warning, not an error — the document is still structurally valid CWL, and a single-element command path that legitimately contains a space is technically allowed; this just flags the common mistake. The check lives in CommandLineTool.__init__ and only fires for the single-string form, so:

  • list-form baseCommand: [tar, xf] → no warning
  • single-word baseCommand: echo → no warning
  • absent baseCommand (e.g. ExpressionTool/Workflow) → no warning

This intentionally scopes to checkbox 1 of #2240 (warn about a space). Checkbox 2 (actually probing PATH / containers for the executable) is a larger, runtime/container-aware change and is left for a follow-up.

Tests

tests/test_validate.py:

  • test_validate_warns_on_basecommand_with_space — asserts the warning text, the offending value, and the suggested list form are logged (captured via a custom logger_handler, matching test_validate_custom_logger), and that exit code is still 0 / "valid CWL".
  • test_validate_no_basecommand_space_warning (parametrized) — list-form and an existing no-baseCommand fixture produce no whitespace warning.

Fixtures: tests/wf/2240-basecommand-space.cwl, tests/wf/2240-basecommand-list.cwl.

I verified the warning test fails against the unpatched code (proving it guards the bug, not a no-op). All 9 tests in tests/test_validate.py pass; black, flake8, and isort are clean on the changed files.


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

…rkflow-language#2240)

A CommandLineTool 'baseCommand' given as a single string with internal
whitespace (e.g. "tar xf" instead of [tar, xf]) is passed to the OS as one
program name, which almost never exists. --validate previously accepted it
silently. Emit a warning at construction time pointing at the offending line
and suggesting the list form. List- and single-word baseCommands are
unaffected.

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.

1 participant