Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions changelog.d/http_server_encoding.breaking.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# HTTP server `encoding` option removed {#http-server-encoding-removed}

## Summary

The deprecated `encoding` option has been removed from the `http` and
`http_server` sources. Configurations using it now fail validation.

## Migration

Replace `encoding` with `decoding` and `framing`:

| Previous `encoding` | `decoding.codec` | `framing.method` |
| --- | --- | --- |
| `text` | `text` | `newline_delimited` |
| `json` | `json` | `bytes` |
| `ndjson` | `json` | `newline_delimited` |
| `binary` | `bytes` | `bytes` |

authors: pront
6 changes: 0 additions & 6 deletions deprecation.d/http-server-encoding.md

This file was deleted.

67 changes: 21 additions & 46 deletions src/sources/http_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ use http::StatusCode;
use http_serde;
use tokio_util::codec::Decoder as _;
use vector_lib::{
codecs::{
BytesDecoderConfig, BytesDeserializerConfig, JsonDeserializerConfig,
NewlineDelimitedDecoderConfig,
decoding::{DeserializerConfig, FramingConfig},
},
codecs::decoding::{DeserializerConfig, FramingConfig},
config::{DataType, LegacyKey, LogNamespace},
configurable::configurable_component,
lookup::{lookup_v2::OptionalValuePath, owned_value_path, path},
Expand All @@ -30,7 +26,7 @@ use crate::{
http::KeepaliveConfig,
serde::{bool_or_struct, default_decoding},
sources::util::{
Encoding, HttpSource,
HttpSource,
http::{HttpMethod, add_headers, add_query_parameters},
},
tls::TlsEnableableConfig,
Expand Down Expand Up @@ -71,6 +67,7 @@ impl SourceConfig for HttpConfig {
/// Configuration for the `http_server` source.
#[configurable_component(source("http_server", "Host an HTTP endpoint to receive logs."))]
#[derive(Clone, Debug)]
#[serde(deny_unknown_fields)]
pub struct SimpleHttpConfig {
/// The socket address to listen for connections on.
///
Expand All @@ -79,13 +76,6 @@ pub struct SimpleHttpConfig {
#[configurable(metadata(docs::examples = "localhost:80"))]
address: SocketAddr,

/// The expected encoding of received data.
///
/// For `json` and `ndjson` encodings, the fields of the JSON objects are output as separate fields.
#[configurable(deprecated)]
#[serde(default)]
encoding: Option<Encoding>,

/// A list of HTTP headers to include in the log event.
///
/// Accepts the wildcard (`*`) character for headers matching a specified pattern.
Expand Down Expand Up @@ -241,37 +231,11 @@ impl SimpleHttpConfig {
}

fn get_decoding_config(&self) -> crate::Result<DecodingConfig> {
if self.encoding.is_some() && (self.framing.is_some() || self.decoding.is_some()) {
return Err("Using `encoding` is deprecated and does not have any effect when `decoding` or `framing` is provided. Configure `framing` and `decoding` instead.".into());
}

let (framing, decoding) = if let Some(encoding) = self.encoding {
match encoding {
Encoding::Text => (
NewlineDelimitedDecoderConfig::new().into(),
BytesDeserializerConfig::new().into(),
),
Encoding::Json => (
BytesDecoderConfig::new().into(),
JsonDeserializerConfig::default().into(),
),
Encoding::Ndjson => (
NewlineDelimitedDecoderConfig::new().into(),
JsonDeserializerConfig::default().into(),
),
Encoding::Binary => (
BytesDecoderConfig::new().into(),
BytesDeserializerConfig::new().into(),
),
}
} else {
let decoding = self.decoding.clone().unwrap_or_else(default_decoding);
let framing = self
.framing
.clone()
.unwrap_or_else(|| decoding.default_stream_framing());
(framing, decoding)
};
let decoding = self.decoding.clone().unwrap_or_else(default_decoding);
let framing = self
.framing
.clone()
.unwrap_or_else(|| decoding.default_stream_framing());

Ok(DecodingConfig::new(
framing,
Expand All @@ -285,7 +249,6 @@ impl Default for SimpleHttpConfig {
fn default() -> Self {
Self {
address: "0.0.0.0:8080".parse().unwrap(),
encoding: None,
headers: Vec::new(),
query_parameters: Vec::new(),
tls: None,
Expand Down Expand Up @@ -596,6 +559,19 @@ mod tests {
crate::test_util::test_generate_config::<SimpleHttpConfig>();
}

#[test]
fn rejects_removed_encoding_field() {
let error = serde_yaml::from_str::<SimpleHttpConfig>(
r#"
address: "0.0.0.0:8080"
encoding: text
"#,
)
.unwrap_err();

assert!(error.to_string().contains("unknown field `encoding`"));
}

#[allow(clippy::too_many_arguments)]
async fn source<'a>(
headers: Vec<String>,
Expand Down Expand Up @@ -628,7 +604,6 @@ mod tests {
SimpleHttpConfig {
address,
headers,
encoding: None,
query_parameters,
response_code,
tls: None,
Expand Down
15 changes: 0 additions & 15 deletions website/cue/reference/components/sources/generated/http.cue
Original file line number Diff line number Diff line change
Expand Up @@ -393,21 +393,6 @@ generated: components: sources: http: configuration: {
}
}
}
encoding: {
deprecated: true
description: """
The expected encoding of received data.

For `json` and `ndjson` encodings, the fields of the JSON objects are output as separate fields.
"""
required: false
type: string: enum: {
binary: "Binary."
json: "JSON."
ndjson: "Newline-delimited JSON."
text: "Plaintext."
}
}
framing: {
description: """
Framing configuration.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,21 +393,6 @@ generated: components: sources: http_server: configuration: {
}
}
}
encoding: {
deprecated: true
description: """
The expected encoding of received data.

For `json` and `ndjson` encodings, the fields of the JSON objects are output as separate fields.
"""
required: false
type: string: enum: {
binary: "Binary."
json: "JSON."
ndjson: "Newline-delimited JSON."
text: "Plaintext."
}
}
framing: {
description: """
Framing configuration.
Expand Down
4 changes: 2 additions & 2 deletions website/cue/reference/components/sources/http_server.cue
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ components: sources: http_server: {
fields: {
message: {
description: "The raw line from the incoming payload."
relevant_when: "encoding == \"text\""
relevant_when: "decoding.codec == \"text\""
required: true
type: string: {
examples: ["Hello world"]
Expand Down Expand Up @@ -91,7 +91,7 @@ components: sources: http_server: {
fields: {
"*": {
description: "Any field contained in your JSON payload"
relevant_when: "encoding != \"text\""
relevant_when: "decoding.codec != \"text\""
required: false
type: "*": {}
}
Expand Down
11 changes: 6 additions & 5 deletions website/data/deprecations.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@
"deprecated_since": "0.56.0",
"description": "The `series_api_version: v1` option is deprecated in favor of `v2` (the default).\nThe v1 series endpoint (`/api/v1/series`) is a legacy endpoint.\n\nUsers should remove `series_api_version: v1` from their configuration or set it to `v2`."
},
{
"what": "`encoding` field on HTTP server sources",
"deprecated_since": "0.50.0",
"description": "The `encoding` field will be removed. Use `decoding` and `framing` instead."
},
{
"what": "Environment-variable and secret placeholders in non-string positions",
"deprecated_since": "0.57.0",
Expand All @@ -37,6 +32,12 @@
"deprecated_since": "0.55.0",
"removed_in": "0.56.0",
"description": "The `greptimedb_metrics` and `greptimedb_logs` sinks drop support for GreptimeDB v0.x.\nUsers must upgrade their GreptimeDB instance to v1.x before upgrading Vector."
},
{
"what": "`encoding` field on HTTP server sources",
"deprecated_since": "0.50.0",
"removed_in": "0.58.0",
"description": "The `encoding` field will be removed. Use `decoding` and `framing` instead."
}
]
}
Loading