Skip to content

disk: keep part_* fields when decoding a partition from TOML - #57

Open
andrewdunndev wants to merge 2 commits into
osbuild:mainfrom
andrewdunndev:fix/toml-partition-part-fields
Open

andrewdunndev wants to merge 2 commits into
osbuild:mainfrom
andrewdunndev:fix/toml-partition-part-fields

Conversation

@andrewdunndev

Copy link
Copy Markdown

Decoding a PartitionCustomization directly from TOML silently drops part_type, part_label and part_uuid, because only UnmarshalJSON assigns them (osbuild/image-builder#1115, osbuild/image-builder#1543). This assigns them in UnmarshalTOML too. Blueprints are not affected, since DiskCustomization decodes its partitions through JSON.

Routing it through unmarshalTOMLviaJSON instead would also work, but changes the TOML error messages the tests pin. I found this while looking at a luks property for partitions (osbuild/image-builder#2609), which would hit the same gap.

PartitionCustomization.UnmarshalTOML never assigns `part_type`,
`part_label` or `part_uuid`, so a partition decoded directly from TOML
silently loses all three. UnmarshalJSON reads them next to `type` and
`minsize` and assigns them once the payload is decoded; do the same in
the TOML decoder.

Blueprints are not affected, because DiskCustomization decodes its
partitions through the JSON path. The fields came in with [1] and [2],
which added the assignments to UnmarshalJSON only.

The type assertions can ignore `ok`: decodePlain, decodeBtrfs and
decodeLVM already reject a non-string value for these keys.

[1]: osbuild/image-builder#1115
[2]: osbuild/image-builder#1543

Signed-off-by: Andrew Dunn <andrew@dunn.dev>
@andrewdunndev
andrewdunndev requested a review from a team as a code owner October 1, 2026 00:58
Comment thread pkg/blueprint/disk_customizations_test.go
Plain stays the empty-case check; plain-with-parts covers the fields.

Signed-off-by: Andrew Dunn <andrew@dunn.dev>

@brlane-rht brlane-rht left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Looks good to me!

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