Skip to content

Commit 8a2f8f6

Browse files
authored
fix: allow empty message_key value in config (#18091)
* fix: allow empty message_key value in config * good opportunity to use a string constant
1 parent 4915b42 commit 8a2f8f6

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

lib/codecs/src/decoding/format/bytes.rs

+12-5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use lookup::OwnedTargetPath;
33
use serde::{Deserialize, Serialize};
44
use smallvec::{smallvec, SmallVec};
55
use vector_core::config::LogNamespace;
6+
use vector_core::schema::meaning;
67
use vector_core::{
78
config::{log_schema, DataType},
89
event::{Event, LogEvent},
@@ -35,11 +36,17 @@ impl BytesDeserializerConfig {
3536
/// The schema produced by the deserializer.
3637
pub fn schema_definition(&self, log_namespace: LogNamespace) -> schema::Definition {
3738
match log_namespace {
38-
LogNamespace::Legacy => schema::Definition::empty_legacy_namespace().with_event_field(
39-
log_schema().message_key().expect("valid message key"),
40-
Kind::bytes(),
41-
Some("message"),
42-
),
39+
LogNamespace::Legacy => {
40+
let definition = schema::Definition::empty_legacy_namespace();
41+
if let Some(message_key) = log_schema().message_key() {
42+
return definition.with_event_field(
43+
message_key,
44+
Kind::bytes(),
45+
Some(meaning::MESSAGE),
46+
);
47+
}
48+
definition
49+
}
4350
LogNamespace::Vector => {
4451
schema::Definition::new_with_default_metadata(Kind::bytes(), [log_namespace])
4552
.with_meaning(OwnedTargetPath::event_root(), "message")

0 commit comments

Comments
 (0)