Skip to content

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

Merged
mr-c merged 1 commit into
common-workflow-language:mainfrom
arimu1:fix/2240-warn-basecommand-space
Jul 20, 2026
Merged

mr-c merged 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
Contributor

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.

@mr-c
mr-c marked this pull request as draft June 25, 2026 13:33
@arimu1
arimu1 force-pushed the fix/2240-warn-basecommand-space branch from daabc03 to d5ae3d1 Compare June 28, 2026 06:41
@codecov

codecov Bot commented Jun 28, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.19%. Comparing base (a49e83f) to head (a8a3e9e).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2292      +/-   ##
==========================================
+ Coverage   85.16%   85.19%   +0.02%     
==========================================
  Files          46       46              
  Lines        8595     8598       +3     
  Branches     2012     2013       +1     
==========================================
+ Hits         7320     7325       +5     
+ Misses        810      807       -3     
- Partials      465      466       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@arimu1
arimu1 force-pushed the fix/2240-warn-basecommand-space branch 2 times, most recently from 8120bb9 to 49768df Compare July 15, 2026 13:21
@arimu1
arimu1 force-pushed the fix/2240-warn-basecommand-space branch from 49768df to 396ad98 Compare July 18, 2026 15:01
…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 <[email protected]>
@arimu1
arimu1 force-pushed the fix/2240-warn-basecommand-space branch from 396ad98 to a8a3e9e Compare July 20, 2026 00:23
@mr-c
mr-c marked this pull request as ready for review July 20, 2026 09:21
@mr-c
mr-c enabled auto-merge (rebase) July 20, 2026 09:22
@mr-c
mr-c disabled auto-merge July 20, 2026 16:43
@mr-c
mr-c merged commit 1f6aa50 into common-workflow-language:main Jul 20, 2026
46 of 47 checks passed
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.

2 participants