Skip to content

Warn when 'format' is used on a non-File parameter (#1616, #607)#2291

Open
arimu1 wants to merge 1 commit into
common-workflow-language:mainfrom
arimu1:fix/537-no-container-cachedir
Open

Warn when 'format' is used on a non-File parameter (#1616, #607)#2291
arimu1 wants to merge 1 commit into
common-workflow-language:mainfrom
arimu1:fix/537-no-container-cachedir

Conversation

@arimu1

@arimu1 arimu1 commented Jun 18, 2026

Copy link
Copy Markdown

Summary

Fixes #1616 and #607.

format is only meaningful for File parameters. cwltool silently accepted it on Directory (and other) inputs/outputs, so --validate passed with no indication that the field would be ignored — exactly the "validation passes with no warnings/errors" behavior reported in #1616, and the "complains far too late" symptom in #607.

$ cwltool --validate format-on-directory.cwl
format-on-directory.cwl is valid CWL.    # before — no hint that `format` is bogus

Change

In Process.__init__ (cwltool/process.py), while iterating the tool's inputs/outputs, emit a warning when a parameter declares format but its type does not contain a File. A small recursive helper _type_contains_file handles plain (File), namespaced, array (File[]), nullable (File?) and record forms.

$ cwltool --validate format-on-directory.cwl
format-on-directory.cwl:10:5: 'format' is only valid for 'File' type parameters, but 'indir' is not a File; the 'format' field will be ignored.
format-on-directory.cwl is valid CWL.    # after

A warning (not a hard error as #607 literally suggested) was chosen so existing documents carrying a harmless stray format keep validating; this also matches the direction in the newer #1616. The warning respects --no-warnings/--quiet like other validation warnings.

Tests

Added tests/wf/format-on-directory.cwl and tests/wf/format-on-file.cwl fixtures, plus two tests in tests/test_validate.py:

  • test_validate_warns_on_format_for_non_file — asserts the warning is emitted (captured via a custom log handler, as test_validate_custom_logger does).
  • test_validate_no_format_warning_for_file — asserts format on a File does not warn.

I verified the warn-test fails against the pre-fix code and passes after, and that the File case never warns. Full test_validate.py passes (8); black/flake8/isort clean.


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

…anguage#1616, common-workflow-language#607)

`format` is only meaningful for File parameters, but cwltool silently
accepted it on Directory (and other) inputs/outputs, so validation
passed with no indication that the field would be ignored.

Emit a validation warning (pointing at the offending `format` line)
when a parameter declares `format` but its type does not contain a
File. File and File[] parameters are unaffected. A warning, rather
than a hard error, avoids breaking documents that currently carry a
harmless stray `format`.

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.

cwltool validate must have a warning when format is used with an invalid type (e.g. Directory)

1 participant