libcnb.rs
libcnb.rs copied to clipboard
`BuildPlanBuilder::or()` can add empty `Or` entries
BuildPlanBuilder
is meant to be used roughly like so:
let build_plan = BuildPlanBuilder::new()
.provides("python")
.provides("pip")
.or()
.provides("python")
.build();
With the resultant build plan eventually being serialised to the TOML format here: https://github.com/buildpacks/spec/blob/main/buildpack.md#build-plan-toml
However if the builder API is mis-used like so:
let build_plan = BuildPlanBuilder::new().or().or().build();
Then the resultant BuildPlan
contains empty Or
entries, like so:
BuildPlan { provides: [], requires: [], or: [Or { provides: [], requires: [] }, Or { provides: [], requires: [] }] }
The empty requires
and provides
Vecs are not serialised, however or
is:
[[or]]
[[or]]
Whilst this use of the API is clearly not correct, it feels like we should:
- Have
BuildPlanBuilder::or()
skip thepush_back()
iff bothcurrent_provides
andcurrent_requires
is empty - Consider adjusting
BuildPlan
to more accurately represent the data model. eg: Should the fields all be anOption
?