Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Ensure strict typing for input defaults to prevent runtime errors #5604

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/src/main/java/io/kestra/core/models/flows/Input.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public abstract class Input<T> implements Data {
@Schema(
title = "The default value to use if no value is specified."
)
Object defaults;
T defaults;

@Schema(
title = "The display name of the input."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,10 +404,10 @@ private Object parseType(Execution execution, Type type, String id, Type element
// Assuming that after the render we must have a double/int, so we can safely use its toString representation
case FLOAT -> current instanceof Float ? current : Float.valueOf(current.toString());
case BOOLEAN -> current instanceof Boolean ? current : Boolean.valueOf((String) current);
case DATETIME -> Instant.parse(((String) current));
case DATE -> LocalDate.parse(((String) current));
case TIME -> LocalTime.parse(((String) current));
case DURATION -> Duration.parse(((String) current));
case DATETIME -> current instanceof Instant ? current : Instant.parse(((String) current));
case DATE -> current instanceof LocalDate ? current : LocalDate.parse(((String) current));
case TIME -> current instanceof LocalTime ? current : LocalTime.parse(((String) current));
case DURATION -> current instanceof Duration ? current : Duration.parse(((String) current));
case FILE -> {
URI uri = URI.create(((String) current).replace(File.separator, "/"));

Expand Down
Loading