Skip to content

Conversation

@letFunny
Copy link
Collaborator

Format v3 uses a map instead of a list for essential and deprecates the field v3-essential which is only used during the transition from v2 to v3.

  • Have you signed the CLA?

Format v3 uses a map instead of a list for `essential` and deprecates
the field `v3-essential` which is only used during the transition from
v2 to v3.
@letFunny letFunny requested a review from niemeyer October 17, 2025 14:11
@github-actions
Copy link

github-actions bot commented Oct 17, 2025

Command Mean [s] Min [s] Max [s] Relative
BASE 12.999 ± 0.411 12.263 13.581 1.04 ± 0.04
HEAD 12.555 ± 0.281 12.228 13.258 1.00

Copy link
Contributor

@niemeyer niemeyer left a comment

Choose a reason for hiding this comment

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

On a first pass, as detailed below it's surprising and unfortunate that this PR seems to make things significantly worse almost everywhere it touches. This was supposed to be a cleanup PR ideally.

},
}

func parseSliceEssential(yamlPkg *yamlPackage, yamlSlice *yamlSlice, slice *Slice) error {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This refactoring makes it hard to track what changed compared to the previous implementation. Could we do the extraction in a dedicated function in another PR?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I thought about that but it is a bit overkill because what happens if we end up changing the approach, then we merged a PR for a refactor that wasn't actually fully needed. As I told you offline, this function needs a bit of love to make it more readable but, if done properly, I think it is easy to see the logic just moved. I will make the changes and we can discuss.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think with the latest changes it is easier to see that the diff is the same.

@letFunny letFunny requested review from niemeyer and upils January 15, 2026 11:04
@letFunny
Copy link
Collaborator Author

As discussed with @niemeyer this week and the previous one, I have changed the PR. The current approach does not need two separate definitions of the same type and instead just changes how the conflicting field is parsed (in > v3 as a map, in v1, v2 as a list). This solution is not as strict as the previous one in regards to chisel info but as agreed it was a good tradeoff.

The complexity that still exists in the current approach is mainly because we need to produce good error messages and discern between all combinations of format + fields.

For the record, Paul and me spent even more time this week thinking about the problem and we also tried:

  • Embedding the struct. It is far more complex because Unmarshal gets the full yaml.Node and needs to write a custom parser for the whole struct, or we are back at duplicating type definitions.
  • Do the parsing of V3Essential and Essential in Unmarshal together is more complex because the format is needed to produce good errors. Adding information in Unmarshal is not simple when structs are created dynamically.
  • Have two different types that support v1/v2 and v3. Discarded in the previous PR based on Gustavo's comment.
  • Have two types with structs embedded. We also discarded it for the similarity with the previous one.
  • Combinations of the previous and cosmetic differences.

Copy link
Collaborator

@upils upils left a comment

Choose a reason for hiding this comment

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

Thanks @letFunny. I have a couple of questions, mainly about tests, but overall it LGTM.

// 'v3-essential' to the shape expected by the v3 format.
// skip is set to true when an accurate translation of the test is not
// possible, for example having duplicates in the list.
func oldEssentialToV3(c *C, input []byte) (out string, skip bool) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

[nitpick]: This is a clever solution to avoid duplicating the test cases but given the complexity I find it a bit hard to know what the final input to the test is.
I also wonder if we really need to rerun this many tests when many of them are not testing the essential resolution logic. I guess we are better safe than sorry but I wonder how hard that will be to maintain, especially when adding new tests.

@letFunny letFunny added the Priority Look at me first label Jan 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Priority Look at me first

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants