vectordotdev/vector · error
Env var DD_ORIGIN_PRODUCT must be an unsigned 32 bit integer
Error message
Env var DD_ORIGIN_PRODUCT must be an unsigned 32 bit integer.
What it means
DD_ORIGIN_PRODUCT is read at compile time via option_env! and parsed lazily at first use by the Datadog metrics encoder. If the build environment exported a value that does not parse as u32, the first metrics encode after startup panics the process. When unset, the default value 14 is used; the variable exists so Datadog internal builds can tag the origin product.
Source
Thrown at src/sinks/datadog/metrics/encoder.rs:49
DatadogSeriesMetricMetadata,
},
proto::fds::protobuf_descriptors,
sinks::util::{Compression, Compressor, encode_namespace, request_builder::EncodeResult},
};
const SERIES_PAYLOAD_HEADER: &[u8] = b"{\"series\":[";
const SERIES_PAYLOAD_FOOTER: &[u8] = b"]}";
const SERIES_PAYLOAD_DELIMITER: &[u8] = b",";
pub(super) const ORIGIN_CATEGORY_VALUE: u32 = 11;
const DEFAULT_DD_ORIGIN_PRODUCT_VALUE: u32 = 14;
pub(super) static ORIGIN_PRODUCT_VALUE: LazyLock<u32> = LazyLock::new(|| {
option_env!("DD_ORIGIN_PRODUCT")
.map(|p| {
p.parse::<u32>()
.expect("Env var DD_ORIGIN_PRODUCT must be an unsigned 32 bit integer.")
})
.unwrap_or(DEFAULT_DD_ORIGIN_PRODUCT_VALUE)
});
#[allow(warnings, clippy::pedantic, clippy::nursery)]
mod ddmetric_proto {
include!(concat!(env!("OUT_DIR"), "/datadog.agentpayload.rs"));
}
#[derive(Debug, Snafu)]
pub enum EncoderError {
#[snafu(display(
"Invalid metric value '{}' was given; '{}' expected",
metric_value,
expected
))]
InvalidMetric {
expected: &'static str,View on GitHub (pinned to 3708c39b12)
Solutions
- Unset or correct the variable in the build environment (unset DD_ORIGIN_PRODUCT, or DD_ORIGIN_PRODUCT=14 cargo build) and rebuild
- Add a build.rs/CI assertion that option_env!("DD_ORIGIN_PRODUCT") parses as u32 when present
- Remove the variable from Dockerfiles/CI env blocks that leak into cargo build when origin tagging is not needed
Example fix
# before (Dockerfile) ENV DD_ORIGIN_PRODUCT=true RUN cargo build --release # after RUN cargo build --release
Defensive patterns
Strategy: validation
Validate before calling
# build.sh / CI step
if [ -n "$DD_ORIGIN_PRODUCT" ]; then
case "$DD_ORIGIN_PRODUCT" in
''|*[!0-9]*) echo "DD_ORIGIN_PRODUCT must be a u32" >&2; exit 1;;
esac
fi
cargo build --release Prevention
- Audit Dockerfiles and CI env blocks for stray DD_* variables
- Assert compile-time env vars parse in a build.rs guard
- Document which env vars are build-time vs run-time for your image
When it happens
Trigger: Building Vector (or a binary embedding this encoder) with DD_ORIGIN_PRODUCT=true, a negative number, a value above u32::MAX, or one containing whitespace/quotes; the panic then occurs at runtime on the first Datadog metrics payload, not at build time.
Common situations: CI images leaking unrelated DD_* variables (Datadog agents, docker build args); pipelines filling the variable from unvalidated secret stores; local shells exporting it for the Datadog agent while building Vector.
Understand the failure class
Background: "is not a valid" / "Invalid ... value" environment variable errors: how libraries validate env vars and what to do when they reject yours — this error's family across 48 libraries.
Related errors
- `error` should be an i64
- `duration` should be an i64
- `parent_id` should be an i64
- message is required (make sure the "message" semantic meanin
- API key should be only valid ASCII characters
AI-assisted analysis of vectordotdev/vector@3708c39b12 (2026-08-20).
Data as JSON: /api/errors/326fc28f26082e0e.
Report an issue: GitHub.