Skip to content

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

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

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
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.08%. Comparing base (5634342) to head (8120bb9).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2292      +/-   ##
==========================================
- Coverage   85.18%   85.08%   -0.10%     
==========================================
  Files          46       46              
  Lines        8593     8596       +3     
  Branches     2011     2012       +1     
==========================================
- Hits         7320     7314       -6     
- Misses        807      814       +7     
- Partials      466      468       +2     

☔ 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.

…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>
@arimu1 arimu1 force-pushed the fix/2240-warn-basecommand-space branch from d5ae3d1 to 8120bb9 Compare July 11, 2026 03:20
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