-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lossy numeric LayerContentMetadata #473
Comments
I dug into the cached docker volume. It looks like the values are stored as integers there:
|
Adding this to let layer_file = std::fs::read_to_string(_ctx.layers_dir.join("counting.toml")).unwrap();
println!("Layer file contents: {layer_file}"); ...gives:
So the issue must either be on write, or a pack/lifecycle thing. |
Ok so this is a pack/lifecycle thing. If I read |
This is enough to repro (create a skeleton buildpack using #!/usr/bin/env bash
set -euo pipefail
layers_dir="${1}"
test_layer_dir="${layers_dir}/test"
test_layer_toml="${test_layer_dir}.toml"
mkdir -p "${test_layer_dir}"
if [[ -f "${test_layer_toml}" ]]; then
echo "Existing layer TOML contents:"
cat "${test_layer_toml}"
fi
cat > "${test_layer_toml}" << EOF
[types]
launch = true
build = true
cache = true
[metadata]
version = 1
EOF ...gives on the second (cached) build:
|
Here's a one stop reproduction script:
Running it twice demonstrates the error ed was seeing:
According to https://toml.io/en/ integers are supported types. I say this is for sure a bug in lifecycle. I'll move to make this bash example an https://codetriage.com/example_app and open an issue against the lifecycle. |
Bash example repro https://github.com/schneems/cnb-metadata-integer-bug |
When using any integer type as part of a Layer's Metadata, that metadata is deemed incompatible when reading from a previous layer.
libcnb.rs
seems to interpret these fields asFloat
.For example,
LayerMetadata
like this:Will always hit the
migrate_incompatible_metadata
method, reporting theGenericMetadata
asSome({"counter_i32": Float(1.0), "counter_u64": Float(1.0)})
.To reproduce:
cargo libcnb package
pack build sample --buildpack target/buildpack/debug/sample-counter
. It should build just fine.pack build sample --buildpack target/buildpack/debug/sample-counter
. It will fail to use the previously cached metadata, and that should show in the build logs.The text was updated successfully, but these errors were encountered: