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
err := dec.Decode(&yamlPkg)
if err != nil {
return nil, fmt.Errorf("cannot parse package %q slice definitions: %v", pkgName, err)
if format == "v1" || format == "v2" {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

[Note for reviewer]: This is the simplest way I found to support all formats without having to duplicate all the logic. We could, for example, use interfaces and have two implementations one for v1/v2 and one for v3, but I didn't like the extra layer of indirection.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's quite surprising that the implementation when we support the three formats in a compatible fashion seems cleaner than the one where we're breaking compatibility with the past to clean it up. Even more when the new format is exactly the same as the old format under a different field name. What am I missing?

Copy link
Collaborator Author

@letFunny letFunny Oct 21, 2025

Choose a reason for hiding this comment

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

I don't fully understand your comment, what do you mean by?

Even more when the new format is exactly the same as the old format under a different field name.

That is true but we need to also support v2 which has a different set of fields (i.e. different type for essential and v3-essential is used).

EDIT: After re-reading it I understood the comment. This is about how we marshal back into yaml (presumably).

Essential map[string]*yamlEssential `yaml:"essential,omitempty"`
// It is only used to present an error message to the user if the field
// is used in v3.
V3Essential map[string]*yamlEssential `yaml:"v3-essential,omitempty"`
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

[Note for reviewer]: We can remove this field completely. I do think the UX is better if we tell the user the field they had been using is now deprecated, this can act as a hint that they need to look at the documentation to see what changed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure, but it may have "any" as the type instead, as we don't care about what it holds, and it shouldn't be touched if yamlEssential changes.

@github-actions
Copy link

github-actions bot commented Oct 17, 2025

Command Mean [s] Min [s] Max [s] Relative
BASE 8.612 ± 0.028 8.576 8.670 1.00
HEAD 8.627 ± 0.065 8.550 8.750 1.00 ± 0.01

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.

Essential map[string]*yamlEssential `yaml:"essential,omitempty"`
// It is only used to present an error message to the user if the field
// is used in v3.
V3Essential map[string]*yamlEssential `yaml:"v3-essential,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Sure, but it may have "any" as the type instead, as we don't care about what it holds, and it shouldn't be touched if yamlEssential changes.

err := dec.Decode(&yamlPkg)
if err != nil {
return nil, fmt.Errorf("cannot parse package %q slice definitions: %v", pkgName, err)
if format == "v1" || format == "v2" {
Copy link
Contributor

Choose a reason for hiding this comment

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

It's quite surprising that the implementation when we support the three formats in a compatible fashion seems cleaner than the one where we're breaking compatibility with the past to clean it up. Even more when the new format is exactly the same as the old format under a different field name. What am I missing?

Archive string `yaml:"archive,omitempty"`
Slices map[string]v1v2YAMLSlice `yaml:"slices,omitempty"`
Essential []string `yaml:"essential,omitempty"`
V3Essential map[string]*yamlEssential `yaml:"v3-essential,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar here.. I don't understand why we're introducing significant duplication for something that before was easier, now that we can break compatibility. It's almost like the hack was cleaner than the straightforward version.

Copy link
Collaborator Author

@letFunny letFunny Oct 21, 2025

Choose a reason for hiding this comment

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

What do you mean by breaking compatibility? The new version of Chisel should be able to read v1, v2 and v3. I am probably missing something about what you meant in the comments here. Maybe you are talking about the shape of the code and you had something specific in mind.

There is another alternative, I can have only one type definition and use any / yaml.Node as the type for Essential both in package and in slice and then do the parsing manually depending on the format version.

return slice, nil
}

type v1v2YAMLSlice struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

If/when we do need such types and functions, it's better to spell this as yamlSliceV2 and yamlSliceV3, instead of v1v2YAMLSlice and yamlSlice. Same for functions, etc.

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