vectordotdev/vector · error
building serializer should never fail
Error message
building serializer should never fail
What it means
Same as the Encoding arm: for InputResource::EncodingWithFraming, into_encoder builds the framing and serializer from the codec config and expects both to succeed. A panic means the serializer half of an encoding-with-framing configuration failed to build despite being assumed pre-validated.
Solutions
- Run the serializer config through build() early in test setup to surface the real codec error.
- Fix the encoding configuration used by the validation test so it satisfies codec constraints.
- Replace the expect with a descriptive panic including the underlying error to speed diagnosis.
Example fix
// before
serializer.build().expect("building serializer should never fail")
// after
serializer.build().unwrap_or_else(|e| panic!("serializer build failed: {e}")) Defensive patterns
Strategy: validation
Validate before calling
// Check both halves of an EncodingWithFraming config early
let (framing, serializer) = config.config();
framing.clone().unwrap_or(FramingConfig::Bytes).build().expect("bad framing");
serializer.build().expect("bad serializer"); Try / catch
serializer.build().unwrap_or_else(|e| panic!("encoding-with-framing serializer invalid: {e}")) Prevention
- Pre-build framing and serializer configs in test setup to get real codec errors.
- After codec crate updates, re-run validation harness smoke tests.
- Avoid hand-rolled EncodingWithFraming configs; derive them from validated component configs.
When it happens
Trigger: spawn_input_http_server/spawn_input_http_client processes an EncodingWithFraming input whose SerializerConfig::build() returns Err at runtime.
Common situations: Invalid codec options (e.g. unsupported serializer settings) in a validation harness config; drift between codec config validation and build() requirements after a refactor.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- should not fail to build serializer
- Timestamp out of range
- a record with a next ID must have an event count
- a source must always have an external resource
- a valid HTTP/1 URI is valid as an HTTP URI
AI-assisted analysis of vectordotdev/vector@bdb87aeaa4 (2026-09-16).
Data as JSON: /api/errors/13d4ccdc1a1cbd9d.
Report an issue: GitHub.
Appendix: source
Thrown at src/components/validation/resources/mod.rs:92
///
/// The encoder is generated as an inverse to the input codec: if a decoding configuration was
/// given, we generate an encoder that satisfies that decoding configuration, and vice versa.
pub fn into_encoder(&self) -> Encoder<encoding::Framer> {
let (framer, serializer) = match self {
Self::Encoding(config) => (
Framer::Bytes(BytesEncoder),
config.build().expect("should not fail to build serializer"),
),
Self::EncodingWithFraming(config) => {
let (maybe_framing, serializer) = config.config();
(
maybe_framing
.clone()
.unwrap_or(FramingConfig::Bytes)
.build(),
serializer
.build()
.expect("building serializer should never fail"),
)
}
Self::Decoding(config) => (
decoder_framing_to_encoding_framer(config.framing()),
deserializer_config_to_serializer(config.config()),
),
};
Encoder::<encoding::Framer>::new(framer, serializer)
}
/// Gets a decoder for this codec.
///
/// The decoder is generated as an inverse to the input codec: if an encoding configuration was
/// given, we generate a decoder that satisfies that encoding configuration, and vice versa.
pub fn into_decoder(&self, log_namespace: LogNamespace) -> vector_lib::Result<Decoder> {
let (framer, deserializer) = match self {
Self::Decoding(config) => return config.build(),View on GitHub (pinned to bdb87aeaa4)