Skip to content

Conversation

@MTarek165
Copy link
Contributor

@MTarek165 MTarek165 commented Dec 6, 2025

closes #13007

Description

  • YAML/JSON nested inputs were passed as Java objects and converted using toString(), which breaks their structure and causes deserialization errors.
  • Nested types (maps, collections) now use proper YAML/JSON serialization to preserve structure.
  • Ensures consistent and correct YAML/JSON parsing for all input types.

Testing

  • Previous tests only covered YAML/JSON provided as plain strings.
  • Added test coverage for YAML/JSON inputs passed as Java objects.
  • Verified that nested structures serialize and deserialize correctly without losing structure.

@MTarek165 MTarek165 changed the title Fix/serialize subflow inputs with type yml properly fix(core): yaml input serialization/deserialization Dec 7, 2025
@MTarek165 MTarek165 changed the title fix(core): yaml input serialization/deserialization fix(core): ensure proper parsing for yaml input type Dec 7, 2025
@MilosPaunovic MilosPaunovic added kind/external Pull requests raised by community contributors area/backend Needs backend code changes labels Dec 8, 2025
Copy link
Member

@loicmathieu loicmathieu left a 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 -> {
Copy link
Member

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);

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Copy link
Member

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

Copy link
Contributor Author

@MTarek165 MTarek165 Dec 8, 2025

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.

@MTarek165
Copy link
Contributor Author

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?

I think the same problem would occur with json in case of subflow, i would check and fix if any

@MTarek165 MTarek165 changed the title fix(core): ensure proper parsing for yaml input type fix(core): ensure proper parsing for yaml/json input types Dec 8, 2025
@MTarek165
Copy link
Contributor Author

@loicmathieu

  • The same issue was happening for json after just replacing the type for parent/subflow example stated in the issue.
  • Now handled it same way as yaml input
  • Covered it in tests and ensured all related tests working properly
    Is there remaining something?

@MTarek165 MTarek165 requested a review from loicmathieu December 8, 2025 13:23
@MTarek165
Copy link
Contributor Author

Everything is ok now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/backend Needs backend code changes kind/external Pull requests raised by community contributors

Projects

Status: To review

Development

Successfully merging this pull request may close these issues.

Subflow with input type YAML are not serializing properly the data

3 participants