-
Notifications
You must be signed in to change notification settings - Fork 2.3k
fix(core): ensure proper parsing for yaml/json input types #13488
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
base: develop
Are you sure you want to change the base?
fix(core): ensure proper parsing for yaml/json input types #13488
Conversation
…of strings or other scalars, only serialize Maps and Collections
…unnerTest - It is related to serializing inputs at resolving phase only - Added Inputs as Java Objects using yml should be serialized/deserialized properly to give the same structure at allValidInputs() test
loicmathieu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if the same issue didn't exist for the JSON input of you set a JSON document as the input default as YAML is a superset of JSON you should be able to define a defailt like this:
- name: json2
type: JSON
defaults: {"some": "input"}Can you test and if it also fail add the same handling for JSON default?
| } | ||
| case JSON -> JacksonMapper.toObject(current.toString()); | ||
| case YAML -> YAML_MAPPER.readValue(current.toString(), JacksonMapper.OBJECT_TYPE_REFERENCE); | ||
| case YAML -> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I undetrstand it, it can only occurs when the value comes from input defaults as here the value will be deserialized as a Map (as a YAML is a Map).
So I think a more compact implementation may be a oneliner like:
case YAML -> current instandof Map ? current : YYAML_MAPPER.readValue(current.toString(), JacksonMapper.OBJECT_TYPE_REFERENCE);There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Not exactly, it can only occurs when passed from subflow, they are passed as Map object, otherwise if a standalone flow using inputs either as default or passed by hand they are json so works properly.
- But regarding check here, I agree, at the end it is map and can be simplified I missed it and will update.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So instead of creating subflow to test it, I focus on inputs only so that if I passed yaml as object they must be retrieved as the same object again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, test can simplify as long as they reproduce what happens in real case scenario
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OOPS the check for Collection is actually necessary.
When I removed it and tested with this structure (same as in the issue):
inputs:
people:
- first: "John"
last: "Doe"
- first: "Jane"
last: "Smith"
The same problem appeared again because the value of input people is a List, not a Map , and that case was no longer handled.
In general, even if YAML is Map but YAML input values can be one of three types:
- Map
- List
- Scalar (string, boolean, int, etc.)
since we care about input values so the correct logic should be:
- If the value is a Map or a List, we should return it as-is (because it is already a proper Java object).
- Otherwise, treat it as a scalar: convert to String and parse it normally.
Because of that, I’m reverting back to the original check that detects both Map and Collection, and I will use List example at test because it is less intuitive.
I think the same problem would occur with json in case of subflow, i would check and fix if any |
|
|
Everything is ok now |
closes #13007
Description
Testing