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(core): keep key order when rendering a Map #4313

Merged
merged 1 commit into from
Jul 15, 2024

Conversation

yvrng
Copy link
Contributor

@yvrng yvrng commented Jul 13, 2024

The VariableRenderer#render() method currently uses a HashMap to store rendered values, and this Map implementation does not preserve order.

This causes a problem when the in parameter is a LinkedHashMap, and you want the order to be preserved.
For example, when using the Produce task in the Kafka plugin (here) with an Avro serializer: the event value is part of the map that is first rendered; the order of the keys must be preserved in order to respect the schema, and currently this leads to serialization problems.

I changed it to LinkedHashMap, ensuring that key ordering is maintained in case a LinkedHashMap is passed as an input.

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.

LGTM

@loicmathieu loicmathieu merged commit 8792b6b into kestra-io:develop Jul 15, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants