2626
2727from mypy_extensions import mypyc_attr
2828from ruamel .yaml .comments import CommentedMap , CommentedSeq
29- from schema_salad .avro .schema import Schema
29+ from schema_salad .avro .schema import RecordSchema
3030from schema_salad .exceptions import ValidationException
3131from schema_salad .ref_resolver import file_uri , uri_file_path
3232from schema_salad .sourceline import SourceLine
@@ -1221,6 +1221,7 @@ def collect_output_ports(
12211221 if cwl_version != "v1.0" :
12221222 builder .resources ["exitCode" ] = rcode
12231223 try :
1224+ expected_schema = cast (RecordSchema , self .names .get_name ("outputs_record_schema" , None ))
12241225 fs_access = builder .make_fs_access (outdir )
12251226 custom_output = fs_access .join (outdir , "cwl.output.json" )
12261227 if fs_access .exists (custom_output ):
@@ -1232,6 +1233,20 @@ def collect_output_ports(
12321233 custom_output ,
12331234 json_dumps (ret , indent = 4 ),
12341235 )
1236+ if ORDERED_VERSIONS .index (cast (str , cwl_version )) >= ORDERED_VERSIONS .index (
1237+ "v1.3.0-dev1"
1238+ ):
1239+ for k in list (ret ):
1240+ found = False
1241+ for field in expected_schema .fields :
1242+ if k == field .name :
1243+ found = True
1244+ break
1245+ if not found :
1246+ _logger .warning (
1247+ f"Discarded undeclared output named { k !r} from { custom_output } ."
1248+ )
1249+ ret .pop (k )
12351250 else :
12361251 for i , port in enumerate (ports ):
12371252 with SourceLine (
@@ -1262,7 +1277,6 @@ def collect_output_ports(
12621277
12631278 if compute_checksum :
12641279 adjustFileObjs (ret , partial (compute_checksums , fs_access ))
1265- expected_schema = cast (Schema , self .names .get_name ("outputs_record_schema" , None ))
12661280 validate_ex (
12671281 expected_schema ,
12681282 ret ,
0 commit comments