Warn when 'format' is used on a non-File parameter (#1616, #607)#2291
Open
arimu1 wants to merge 1 commit into
Open
Warn when 'format' is used on a non-File parameter (#1616, #607)#2291arimu1 wants to merge 1 commit into
arimu1 wants to merge 1 commit into
Conversation
…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>
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.
Summary
Fixes #1616 and #607.
formatis only meaningful forFileparameters. cwltool silently accepted it onDirectory(and other) inputs/outputs, so--validatepassed 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.Change
In
Process.__init__(cwltool/process.py), while iterating the tool'sinputs/outputs, emit a warning when a parameter declaresformatbut its type does not contain aFile. A small recursive helper_type_contains_filehandles plain (File), namespaced, array (File[]), nullable (File?) and record forms.A warning (not a hard error as #607 literally suggested) was chosen so existing documents carrying a harmless stray
formatkeep validating; this also matches the direction in the newer #1616. The warning respects--no-warnings/--quietlike other validation warnings.Tests
Added
tests/wf/format-on-directory.cwlandtests/wf/format-on-file.cwlfixtures, plus two tests intests/test_validate.py:test_validate_warns_on_format_for_non_file— asserts the warning is emitted (captured via a custom log handler, astest_validate_custom_loggerdoes).test_validate_no_format_warning_for_file— assertsformaton aFiledoes 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.pypasses (8);black/flake8/isortclean.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.