Skip to content

armgit / xerj

Public Imported from GitHub
0

AI search engine and MCP server for bots and agents. One Rust binary indexes code, docs, logs, JSONL/CSV and PDFs for BM25 full-text, vector and hybrid search, code search without grep, agent memory and RAG. Elasticsearch-compatible API; Corpus Hub serves hundreds of reference memory corpora.

fix(es-compat): stop sending an empty `Warning: 299` header on every response (#1285)

Vincenzo Lombardoaf9a6a0605ae
diff --git a/engine/crates/xerj-api/src/router.rs b/engine/crates/xerj-api/src/router.rs
index cbce006fb..f5f2ecdfc 100644
--- a/engine/crates/xerj-api/src/router.rs
+++ b/engine/crates/xerj-api/src/router.rs
@@ -1087,10 +1087,11 @@ async fn es_headers_middleware(
"x-elastic-product",
HeaderValue::from_static("Elasticsearch"),
);
- // RFC 7234 warning header — signals no specific deprecation for now.
- if let Ok(v) = HeaderValue::from_str("299 Elasticsearch-8.13.0 \"\"") {
- headers.insert("warning", v);
- }
+ // No `Warning` header here (#1285). ES sends `Warning: 299 …` only
+ // when a request hit a deprecation, always with its message; an empty
+ // one on every response made official clients raise a blank
+ // deprecation warning per call (elasticsearch-py turns each header
+ // into an `ElasticsearchWarning`).
}
resp
}
@@ -1335,6 +1336,20 @@ mod tests {
);
}
+ /// #1285: an Elastic-shaped caller must not get a `Warning` header when
+ /// nothing is deprecated. It used to be `299 Elasticsearch-8.13.0 ""` on
+ /// every response; ES 8.13.4 sends none on `/`, `_search`,
+ /// `_cluster/health` or `_cat/indices`.
+ #[tokio::test]
+ async fn elastic_caller_gets_no_empty_warning_header() {
+ let headers = headers_for("elasticsearch").await;
+ assert!(
+ !headers.contains_key("warning"),
+ "no deprecation happened, so no Warning header: {:?}",
+ headers.get("warning")
+ );
+ }
+
#[tokio::test]
async fn embedding_identity_is_sanitized_machine_readable_native_data() {
for app in [