Fix InputBuilder lazy initialization to prevent validation errors#1444
Fix InputBuilder lazy initialization to prevent validation errors#1444ricardozanini wants to merge 4 commits into
Conversation
…n errors in runtime Signed-off-by: Ricardo Zanini <ricardozanini@gmail.com>
|
AI generated the tests and the PR description. |
|
@fjtirado why running |
There was a problem hiding this comment.
Pull request overview
This PR updates the fluent InputBuilder to avoid constructing invalid Input objects by default, addressing runtime validation errors that occurred when only schema was set (without from). It also adds a new builder method to support inline JSON-schema strings and introduces a comprehensive unit test suite for the builder.
Changes:
- Make
InputBuilderlazily initializefrom(InputFrom) andschema(SchemaUnion) instead of eagerly creating them in the constructor. - Add
schemaAsJsonString(String)to allow setting an inline schema when the schema is available as a JSON string (distinct from the external-URIschema(String)overload). - Add a new
InputBuilderTestsuite covering lazy initialization and field-variant switching behavior.
Reviewed changes
Copilot reviewed 2 out of 6 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
fluent/spec/src/main/java/io/serverlessworkflow/fluent/spec/InputBuilder.java |
Removes eager initialization and adds lazy init + schemaAsJsonString() support. |
fluent/spec/src/test/java/io/serverlessworkflow/fluent/spec/InputBuilderTest.java |
Adds unit tests validating lazy initialization and builder behavior across variants. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Ricardo Zanini <ricardozanini@gmail.com>
There was a problem hiding this comment.
These db files I guess were added uinentionally
There was a problem hiding this comment.
I asked this to you. They were generated with just mvn clean install. I think there's something wrong there.
There was a problem hiding this comment.
In the diff, there's only meta changes - the tests are passing.
There was a problem hiding this comment.
Yes, I have to take a look, but I think we should not couple it with this PR
Summary
Fixed
InputBuilderto use lazy initialization instead of eagerly creatingfromandschemaobjects in the constructor.Problem
When users set only a
schemawithoutfrom, the constructor pre-initialized an emptyInputFromobject, causing validation errors at runtime:Users had to work around this by calling
build().setFrom(null)explicitly.Solution
fromorschemaschemaAsJsonString()method for JSON string schemasTesting
InputBuilderAgenticFlowuse caseChanges
InputBuilder.java: Lazy initialization + null-safe methodsInputBuilderTest.java: New comprehensive test suite