{"record":{"id":"52c3af9129b25b82","repo":"vectordotdev/vector","slug":"should-not-fail-to-build-serializer","errorCode":null,"errorMessage":"should not fail to build serializer","messagePattern":"should not fail to build serializer","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/components/validation/resources/mod.rs","lineNumber":81,"sourceCode":"    /// represent the data in a particular event type) so we must check at runtime to ensure that\n    /// we're only generating event payloads that can be encoded/decoded for the given component.\n    pub fn allowed_event_data_types(self) -> DataType {\n        match self {\n            Self::Encoding(encoding) => encoding.config().input_type(),\n            Self::EncodingWithFraming(encoding) => encoding.config().1.input_type(),\n            Self::Decoding(decoding) => decoding.config().output_type(),\n        }\n    }\n\n    /// Gets an encoder for this codec.\n    ///\n    /// The encoder is generated as an inverse to the input codec: if a decoding configuration was\n    /// given, we generate an encoder that satisfies that decoding configuration, and vice versa.\n    pub fn into_encoder(&self) -> Encoder<encoding::Framer> {\n        let (framer, serializer) = match self {\n            Self::Encoding(config) => (\n                Framer::Bytes(BytesEncoder),\n                config.build().expect(\"should not fail to build serializer\"),\n            ),\n            Self::EncodingWithFraming(config) => {\n                let (maybe_framing, serializer) = config.config();\n                (\n                    maybe_framing\n                        .clone()\n                        .unwrap_or(FramingConfig::Bytes)\n                        .build(),\n                    serializer\n                        .build()\n                        .expect(\"building serializer should never fail\"),\n                )\n            }\n            Self::Decoding(config) => (\n                decoder_framing_to_encoding_framer(config.framing()),\n                deserializer_config_to_serializer(config.config()),\n            ),\n        };","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/vectordotdev/vector/blob/bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013/src/components/validation/resources/mod.rs#L63-L99","documentation":"into_encoder builds the inverse encoder from a validation input's encoding configuration. The codec serializer config is expected to have been validated at config-parse time, so SerializerConfig::build() is unwrapped with an expect; a panic here means an encoding config reached runtime that the codec layer rejects (which the config validator should have caught).","triggerScenarios":"spawn_input_http_server or spawn_input_http_client calls into_encoder on an InputResource::Encoding whose SerializerConfig::build() returns Err — i.e. a serializer configuration invalid per codec rules slipped past validation.","commonSituations":"A newly added or mis-validated serializer option in a validation test harness; codec crate changes that tighten build() constraints without updating the validation resources code.","solutions":["Validate the serializer config via config.build() in test setup before calling into_encoder to get a real error message.","Check which serializer option fails build() and correct the test's encoding configuration.","If a codec constraint changed, update the validation resource configs to satisfy it (or add an early error path instead of expect)."],"exampleFix":"// before\nconfig.build().expect(\"should not fail to build serializer\")\n// after\nconfig.build().unwrap_or_else(|e| panic!(\"invalid serializer config: {e}\"))","handlingStrategy":"validation","validationCode":"// Pre-check the serializer config before it reaches the harness\nlet serializer = encoding_config.build()\n    .expect(\"invalid serializer config in test setup\");","typeGuard":null,"tryCatchPattern":"match config.build() {\n    Ok(s) => s,\n    Err(e) => panic!(\"test encoding config invalid: {e}\"),\n}","preventionTips":["Validate codec/serializer configs via build() at the start of the test, not deep in the harness.","Keep validation-resource encoding configs in sync with codec crate constraints.","Run the component's own config tests after codec upgrades."],"tags":["codec","serializer","panic","internal"],"backgroundTag":"internal-invariant-violation","analyzedSha":"bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013","analyzedAt":"2026-09-16T02:53:35.741Z","contentChangedAt":"2026-09-16T02:53:35.741Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}