Skip to content

Commit

Permalink
fix: allow empty message_key value in config (vectordotdev#18091)
Browse files Browse the repository at this point in the history
* fix: allow empty message_key value in config

* good opportunity to use a string constant
  • Loading branch information
pront authored Jul 28, 2023
1 parent 4915b42 commit 8a2f8f6
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions lib/codecs/src/decoding/format/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use lookup::OwnedTargetPath;
use serde::{Deserialize, Serialize};
use smallvec::{smallvec, SmallVec};
use vector_core::config::LogNamespace;
use vector_core::schema::meaning;
use vector_core::{
config::{log_schema, DataType},
event::{Event, LogEvent},
Expand Down Expand Up @@ -35,11 +36,17 @@ impl BytesDeserializerConfig {
/// The schema produced by the deserializer.
pub fn schema_definition(&self, log_namespace: LogNamespace) -> schema::Definition {
match log_namespace {
LogNamespace::Legacy => schema::Definition::empty_legacy_namespace().with_event_field(
log_schema().message_key().expect("valid message key"),
Kind::bytes(),
Some("message"),
),
LogNamespace::Legacy => {
let definition = schema::Definition::empty_legacy_namespace();
if let Some(message_key) = log_schema().message_key() {
return definition.with_event_field(
message_key,
Kind::bytes(),
Some(meaning::MESSAGE),
);
}
definition
}
LogNamespace::Vector => {
schema::Definition::new_with_default_metadata(Kind::bytes(), [log_namespace])
.with_meaning(OwnedTargetPath::event_root(), "message")
Expand Down

0 comments on commit 8a2f8f6

Please sign in to comment.