Skip to content

SED-4912 yaml formatting improve ordering of fields - #699

Open
cmisev wants to merge 8 commits into
SED-4429-step-ap-idefrom
SED-4912-yaml-formatting-improve-ordering-of-fields
Open

SED-4912 yaml formatting improve ordering of fields#699
cmisev wants to merge 8 commits into
SED-4429-step-ap-idefrom
SED-4912-yaml-formatting-improve-ordering-of-fields

Conversation

@cmisev

@cmisev cmisev commented Aug 28, 2026

Copy link
Copy Markdown

No description provided.

@cmisev
cmisev requested a review from jeromecomte August 28, 2026 19:49

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a mechanism to control the serialization order of fields in YAML models using a new @YamlFieldOrder annotation and YamlFieldPriority enum. It updates several YAML model classes and configures a custom Jackson serializer modifier to enforce this ordering. The review feedback highlights a critical compilation error in SimpleYamlArtefact.java due to a non-existent Jackson method, suggests a performance optimization in YamlPlanReader.java to avoid redundant reflection calls, and recommends renaming the enum constants in YamlFieldPriority to adhere to standard Java naming conventions.

Comment thread step-core/src/main/java/step/core/yaml/model/SimpleYamlArtefact.java Outdated
Comment thread step-core-model/src/main/java/step/core/yaml/YamlFieldPriority.java
…-ordering-of-fields' into SED-4912-yaml-formatting-improve-ordering-of-fields
@cmisev
cmisev requested a review from david-stephan September 4, 2026 08:26
protected List<NamedYamlArtefact> children = new ArrayList<>();

@YamlFieldCustomCopy
@YamlFieldOrder(YamlFieldPriority.LOW)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't tested it, but according to the modify JSON schema on this branch the order is now children -> before -> after instead of before > children > after. Please check it and also if we already have unit tests that validates it.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The json schema does not seem to enforce ordering, and from what I saw in the generated json the order is completely reverse. Rudimentary covarage is given by the ap collection unit tests but you are right we should add some more. Will do.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @david-stephan I added the unit tests

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, for the test. I guess the order in the schema may impact the auto-completion in intellij, but that's another topic.

@@ -71,7 +74,18 @@ protected void fillYamlArtefactFields(T artefact) {

public ObjectNode toFullJson() {
ObjectNode jsonNode = yamlObjectMapper.valueToTree(this);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems relatively complex also in term of perforamnce, and previously the setAll would override any existing properties values with the one of the fieldValues object. Not verified, but it seems that @JsonAnyGetter would be more adapted

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JsonAnyGetter won't control for field ordering, tried that. My honest opinion is that SimpleYAMLArtefact as a whole introduces a lot of complexity and breaks many of the rich features and conventions of the Jackson library, with all the conversions to and from object to JsonObject. Even the avoidance of printing default values in the yaml is perfectly well covered by Jackson annotations and does not require any copying back and forth.

This complexity with the SimpleYamlArtefact is also the primary reason why all my ideas for the diff engine fell flat at the beginning of the year. I'd love to get rid of this altogether, but I always deemed it too much of a can of worms. But maybe with the knowledge I have now it would be of great benefit down the road to simplify it. Let me know if I should tackle this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We know that we have to review and refactor the whole implementation around reading/writing YAML for AP entities in order to algin it, simplify it, make it more pluggable, but not something we achieve for the next major release.

@cmisev
cmisev requested a review from david-stephan September 4, 2026 13:55
@@ -71,7 +74,18 @@ protected void fillYamlArtefactFields(T artefact) {

public ObjectNode toFullJson() {
ObjectNode jsonNode = yamlObjectMapper.valueToTree(this);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We know that we have to review and refactor the whole implementation around reading/writing YAML for AP entities in order to algin it, simplify it, make it more pluggable, but not something we achieve for the next major release.

protected List<NamedYamlArtefact> children = new ArrayList<>();

@YamlFieldCustomCopy
@YamlFieldOrder(YamlFieldPriority.LOW)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, for the test. I guess the order in the schema may impact the auto-completion in intellij, but that's another topic.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants