{"record":{"id":"e02996d17fae0d60","repo":"vectordotdev/vector","slug":"should-not-fail-to-encode-output-event","errorCode":null,"errorMessage":"should not fail to encode output event","messagePattern":"should not fail to encode output event","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/components/validation/runner/mod.rs","lineNumber":693,"sourceCode":"                        output_events.extend(events.clone());\n\n                        // Update the runner metrics for the received event. This will later\n                        // be used in the Validators, as the \"expected\" case.\n                        let mut output_runner_metrics = output_runner_metrics.lock().await;\n\n                        if component_type != ComponentType::Sink {\n                            for output_event in events {\n                                // The event is wrapped in a Vec to match the actual event storage in\n                                // the real topology\n                                output_runner_metrics.received_event_bytes_total +=\n                                    vec![&output_event].estimated_json_encoded_size_of().get() as u64;\n\n                                if let Some(encoder) = maybe_encoder.as_ref() {\n                                    let mut buffer = BytesMut::new();\n                                    encoder\n                                        .clone()\n                                        .encode(output_event, &mut buffer)\n                                        .expect(\"should not fail to encode output event\");\n\n                                    output_runner_metrics.received_events_total += 1;\n                                    output_runner_metrics.received_bytes_total += buffer.len() as u64;\n                                }\n                            }\n                        }\n                        if output_events.len() >= expected_events {\n                            info!(\"Output driver has received all expected events.\");\n                            break\n                        }\n                    } else {\n                        // The channel closed on us.\n                        // This shouldn't happen because in the runner we should not shutdown the external\n                        // resource until this output driver task is complete.\n                        error!(\"Output driver channel with external resource closed.\");\n                        break\n                    }\n                }","sourceCodeStart":675,"sourceCodeEnd":711,"githubUrl":"https://github.com/vectordotdev/vector/blob/bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013/src/components/validation/runner/mod.rs#L675-L711","documentation":"The output driver optionally encodes each received output event using the provided encoder (e.g. a codec configured for the test) to compute received-bytes metrics. Encoding is expected to succeed for any event that the topology produced, so an Err aborts with this expect. It indicates an encoder/event incompatibility rather than a test logic failure.","triggerScenarios":"spawn_output_driver receiving an event the configured encoder cannot serialize — e.g. a JSON/text codec asked to encode an event containing non-UTF-8 bytes, unsupported value types after a codec change, or a codec with strict serialization rules (e.g. Avro schema mismatch).","commonSituations":"Validation tests using an encoding config whose codec can't represent all event value types produced by the transform under test; codec library upgrades adding strictness; events containing binary/regex-derived values passed through a text encoder.","solutions":["Log the encoding error and the offending event (replace expect with unwrap_or_else) to see the incompatible value.","Choose a codec in the test's encoding config that supports all value types the component emits (e.g. JSON with fallible handling).","If a codec upgrade caused it, adjust the event normalization or pin/patch the codec version."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// ensure codec supports all value types the component can emit before the test\nassert!(encoder_supports(&output_event), \"codec cannot encode event\");","typeGuard":null,"tryCatchPattern":"encoder.clone().encode(output_event, &mut buffer)\n    .unwrap_or_else(|e| panic!(\"encode failed for event {output_event:?}: {e}\"));","preventionTips":["Pick a codec in the test encoding config that covers every value type the component emits.","Avoid routing binary/non-UTF-8 values through text-only encoders in validation tests.","Pin and review codec dependency upgrades for added strictness."],"tags":["encoding","codec","validation"],"backgroundTag":"json-serialization-failed","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"}