{"record":{"id":"326fc28f26082e0e","repo":"vectordotdev/vector","slug":"env-var-dd-origin-product-must-be-an-unsigned-32-b","errorCode":null,"errorMessage":"Env var DD_ORIGIN_PRODUCT must be an unsigned 32 bit integer.","messagePattern":"Env var DD_ORIGIN_PRODUCT must be an unsigned 32 bit integer\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/sinks/datadog/metrics/encoder.rs","lineNumber":49,"sourceCode":"        DatadogSeriesMetricMetadata,\n    },\n    proto::fds::protobuf_descriptors,\n    sinks::util::{Compression, Compressor, encode_namespace, request_builder::EncodeResult},\n};\n\nconst SERIES_PAYLOAD_HEADER: &[u8] = b\"{\\\"series\\\":[\";\nconst SERIES_PAYLOAD_FOOTER: &[u8] = b\"]}\";\nconst SERIES_PAYLOAD_DELIMITER: &[u8] = b\",\";\n\npub(super) const ORIGIN_CATEGORY_VALUE: u32 = 11;\n\nconst DEFAULT_DD_ORIGIN_PRODUCT_VALUE: u32 = 14;\n\npub(super) static ORIGIN_PRODUCT_VALUE: LazyLock<u32> = LazyLock::new(|| {\n    option_env!(\"DD_ORIGIN_PRODUCT\")\n        .map(|p| {\n            p.parse::<u32>()\n                .expect(\"Env var DD_ORIGIN_PRODUCT must be an unsigned 32 bit integer.\")\n        })\n        .unwrap_or(DEFAULT_DD_ORIGIN_PRODUCT_VALUE)\n});\n\n#[allow(warnings, clippy::pedantic, clippy::nursery)]\nmod ddmetric_proto {\n    include!(concat!(env!(\"OUT_DIR\"), \"/datadog.agentpayload.rs\"));\n}\n\n#[derive(Debug, Snafu)]\npub enum EncoderError {\n    #[snafu(display(\n        \"Invalid metric value '{}' was given; '{}' expected\",\n        metric_value,\n        expected\n    ))]\n    InvalidMetric {\n        expected: &'static str,","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/vectordotdev/vector/blob/3708c39b12a93212ed8b8d7510b4cc7769cb5864/src/sinks/datadog/metrics/encoder.rs#L31-L67","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before (Dockerfile)\nENV DD_ORIGIN_PRODUCT=true\nRUN cargo build --release\n\n# after\nRUN cargo build --release","handlingStrategy":"validation","validationCode":"# build.sh / CI step\nif [ -n \"$DD_ORIGIN_PRODUCT\" ]; then\n  case \"$DD_ORIGIN_PRODUCT\" in\n    ''|*[!0-9]*) echo \"DD_ORIGIN_PRODUCT must be a u32\" >&2; exit 1;;\n  esac\nfi\ncargo build --release","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["rust","vector","datadog","build-time","env-var","panic"],"backgroundTag":"invalid-env-var-value","analyzedSha":"3708c39b12a93212ed8b8d7510b4cc7769cb5864","analyzedAt":"2026-08-20T07:02:18.786Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T20:17:18.057Z"}