Validate record fields of process record inputs at runtime - #7692
Merged
Merged
Conversation
Type errors are only reported as warnings by `nextflow run`, so a named record input (e.g. `sample: Sample`) previously accepted any record. Check each declared field of the record type: a missing non-nullable field fails the task and a mismatched field type is reported as a warning, consistent with other typed inputs. Signed-off-by: Ben Sherman <bentshermann@gmail.com>
✅ Deploy Preview for nextflow-docs canceled.
|
Collaborator
|
This is good for really early, defensive programming. Making sure no-one accidentally messes up the inputs. For a workflow: nextflow.enable.types = true
record MyInput {
greeting: String
world: String
language: String
}
process HELLO {
input:
sample: MyInput
output:
record(greeting: sample.greeting, language: sample.language, complete: file("output.txt"))
script:
"""
echo "${sample.greeting} ${sample.world} (${sample.language})" > output.txt
"""
}
workflow {
sample = channel.of(
record(greeting: "world", language: "English")
)
HELLO(sample)
}N E X T F L O W ~ version 26.09.1-edge
Launching `main.nf` [festering_varahamihira] - revision: b6e248a8c7
WARN: Type checking found 1 error(s) -- run `nextflow lint` to inspect them
ERROR ~ Error executing process > 'HELLO (1)'
Caused by:
[HELLO (1)] input field `world` at index 0 cannot be null -- append `?` to the type annotation to mark it as nullable
Tip: you can replicate the issue by changing to the process work dir and entering the command `bash .command.run`
-- Check '.nextflow.log' file for detailsFor AI, I expect this to be pretty powerful to allow it to iterate quickly. The question is, is this too aggressive for some users? Forcing them to be very strict with records may slow them down. |
jorgee
approved these changes
Sep 29, 2026
This was referenced Sep 30, 2026
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.
Close #7133
Type errors are only warnings in
nextflow run(full type checking lives innextflow lint, #7656), andisAssignableFromtreats any two record types as compatible. As a result, a process input declared with a named record type (sample: Sample) accepted any record at runtime, including ones missing required fields.This PR checks each declared field of the record type when the input is bound, using the same rules destructured record inputs already follow:
input field `id` at index 0 cannot be null -- append `?` ...invalid argument type for input field `id` at index 0 -- expected a Boolean but got a StringNested records are checked recursively. Type mismatches stay warnings because a hard error would give false positives at runtime (e.g.
GStringforString,LongforInteger).Example (field
worldis missing):Before: task runs with
world = null. After: the task fails with the error above.Added a test to
DataflowTypesTest. It fails without this change.