bottlerocket-os / bottlerocket-os/twoliter
buildsys: validate manifest metadata when deserializing
- Dominant language
- Rust
- Stars
- 34
- Forks
- 43
- Avg merge
- 11h 13m
- Merged PRs (30d)
- 16
Description
The `ManifestInfo` type deserializes certain sections from Cargo.toml
- `package.metadata.build-package`
- `package.metadata.build-kit`
- `package.metadata.build-variant`
Currently the differences between build-package, build-kit and build-variant is not constrained by an enum. This leads to a lot of "late binding" errors if an expected field is missing. Instead a different type for each of these should be created. For example:
```rust
struct BuildPackageInfo { }
struct BuildKitInfo { }
struct BuildVariantInfo { }
enum BuildsysMetadata {
Package(BuildPackageInfo),
Kit(BuildKitInfo),
Variant(BuildVariantInfo),
}
```
If serde is used correctly with this structure, then missing information will cause an error at deserialization time and get rid of Options and errors downstream when fields are being accessed.
---
We should create an issue, if we don't have one already, for deserializing these manifest metadata sections with Serde in a validating manner. We should catch these errors earlier.
_Originally posted by @webern in https://github.com/bottlerocket-os/twoliter/pull/271#discussion_r1628513941_
Contributor guide
Research direction
Start at the ManifestInfo deserialization path and inspect how package.metadata.build-package, build-kit, and build-variant are represented from Cargo.toml. Define the validation boundaries for each metadata section and confirm that missing required information fails during deserialization rather than through downstream field access.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- build-system
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100