From 6589bafb104d295f677e461c462e9de6346a09f2 Mon Sep 17 00:00:00 2001 From: Cody Date: Mon, 6 Apr 2026 02:54:12 -0400 Subject: [PATCH 1/2] fix(ui): use HeaderValue::from_static instead of parse().unwrap() Replaces the only unwrap() in production server code with a compile-time-safe HeaderValue construction. Co-Authored-By: Claude Opus 4.6 (1M context) --- crates/dkdc-db-server/src/ui.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/dkdc-db-server/src/ui.rs b/crates/dkdc-db-server/src/ui.rs index 5f63005..a4c8dab 100644 --- a/crates/dkdc-db-server/src/ui.rs +++ b/crates/dkdc-db-server/src/ui.rs @@ -888,7 +888,7 @@ async fn api_drop_db(State(mgr): State, Path(name): Path) -> R let mut response = Html(String::new()).into_response(); response .headers_mut() - .insert("HX-Redirect", "/ui".parse().unwrap()); + .insert("HX-Redirect", http::HeaderValue::from_static("/ui")); response } Err(e) => Html(format!( From 01babd9813154c37614b040b6371fec11b61a1a8 Mon Sep 17 00:00:00 2001 From: Cody Date: Mon, 6 Apr 2026 03:40:20 -0400 Subject: [PATCH 2/2] fix: use axum::http::HeaderValue and document catalog unwrap invariants - Fix ui.rs: use axum::http::HeaderValue::from_static (was http::) - Fix catalog.rs: avoid bare unwrap in quote parsing, add expect() with invariant documentation for peeked char consumption Co-Authored-By: Claude Opus 4.6 (1M context) --- crates/dkdc-db-core/src/catalog.rs | 6 ++++-- crates/dkdc-db-server/src/ui.rs | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/crates/dkdc-db-core/src/catalog.rs b/crates/dkdc-db-core/src/catalog.rs index 166b66c..9643749 100644 --- a/crates/dkdc-db-core/src/catalog.rs +++ b/crates/dkdc-db-core/src/catalog.rs @@ -229,7 +229,8 @@ fn extract_name_token(s: &str) -> Option { if ch == '"' || ch == '`' || ch == '\'' { // Quoted segment: read until matching close quote let quote = ch; - result.push(chars.next().unwrap()); + chars.next(); // consume the opening quote (peeked above) + result.push(quote); loop { let c = chars.next()?; // unclosed quote → None result.push(c); @@ -241,7 +242,8 @@ fn extract_name_token(s: &str) -> Option { // End of name token break; } else { - result.push(chars.next().unwrap()); + // Safe: peek() confirmed a char exists above + result.push(chars.next().expect("peeked char")); } } diff --git a/crates/dkdc-db-server/src/ui.rs b/crates/dkdc-db-server/src/ui.rs index a4c8dab..a1cdb67 100644 --- a/crates/dkdc-db-server/src/ui.rs +++ b/crates/dkdc-db-server/src/ui.rs @@ -888,7 +888,7 @@ async fn api_drop_db(State(mgr): State, Path(name): Path) -> R let mut response = Html(String::new()).into_response(); response .headers_mut() - .insert("HX-Redirect", http::HeaderValue::from_static("/ui")); + .insert("HX-Redirect", axum::http::HeaderValue::from_static("/ui")); response } Err(e) => Html(format!(