fix: resolve clippy uninlined_format_args in integrations and related modules

Replace format!("msg: {}", var) with format!("msg: {var}") across 8 files
to satisfy the uninlined_format_args lint (-D warnings) in CI run 178.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Shaun Arman 2026-04-04 12:16:29 -05:00
parent 64492c743b
commit bdb63f3aee
8 changed files with 84 additions and 88 deletions

View File

@ -97,9 +97,9 @@ mod tests {
for i in 0..5 { for i in 0..5 {
write_audit_event( write_audit_event(
&conn, &conn,
&format!("action_{}", i), &format!("action_{i}"),
"test", "test",
&format!("id_{}", i), &format!("id_{i}"),
"{}", "{}",
) )
.unwrap(); .unwrap();

View File

@ -94,7 +94,7 @@ pub async fn initiate_oauth(
let (mut callback_rx, shutdown_tx) = let (mut callback_rx, shutdown_tx) =
crate::integrations::callback_server::start_callback_server(8765) crate::integrations::callback_server::start_callback_server(8765)
.await .await
.map_err(|e| format!("Failed to start callback server: {}", e))?; .map_err(|e| format!("Failed to start callback server: {e}"))?;
// Store shutdown channel // Store shutdown channel
{ {
@ -123,7 +123,7 @@ pub async fn initiate_oauth(
let mut oauth_state = match OAUTH_STATE.lock() { let mut oauth_state = match OAUTH_STATE.lock() {
Ok(state) => state, Ok(state) => state,
Err(e) => { Err(e) => {
tracing::error!("Failed to lock OAuth state: {}", e); tracing::error!("Failed to lock OAuth state: {e}");
continue; continue;
} }
}; };
@ -148,7 +148,7 @@ pub async fn initiate_oauth(
match result { match result {
Ok(_) => tracing::info!("OAuth callback handled successfully"), Ok(_) => tracing::info!("OAuth callback handled successfully"),
Err(e) => tracing::error!("OAuth callback failed: {}", e), Err(e) => tracing::error!("OAuth callback failed: {e}"),
} }
} }
@ -166,7 +166,7 @@ pub async fn initiate_oauth(
{ {
let mut oauth_state = OAUTH_STATE let mut oauth_state = OAUTH_STATE
.lock() .lock()
.map_err(|e| format!("Failed to lock OAuth state: {}", e))?; .map_err(|e| format!("Failed to lock OAuth state: {e}"))?;
oauth_state.insert( oauth_state.insert(
state_key.clone(), state_key.clone(),
(service.clone(), pkce.code_verifier.clone()), (service.clone(), pkce.code_verifier.clone()),
@ -193,7 +193,7 @@ pub async fn initiate_oauth(
// ServiceNow uses basic auth, not OAuth2 // ServiceNow uses basic auth, not OAuth2
return Err("ServiceNow uses basic authentication, not OAuth2".to_string()); return Err("ServiceNow uses basic authentication, not OAuth2".to_string());
} }
_ => return Err(format!("Unknown service: {}", service)), _ => return Err(format!("Unknown service: {service}")),
}; };
let auth_url = crate::integrations::auth::build_auth_url( let auth_url = crate::integrations::auth::build_auth_url(
@ -231,7 +231,7 @@ async fn handle_oauth_callback_internal(
.unwrap_or_else(|_| "ado-client-id-placeholder".to_string()), .unwrap_or_else(|_| "ado-client-id-placeholder".to_string()),
"http://localhost:8765/callback", "http://localhost:8765/callback",
), ),
_ => return Err(format!("Unknown service: {}", service)), _ => return Err(format!("Unknown service: {service}")),
}; };
// Exchange authorization code for access token // Exchange authorization code for access token
@ -265,7 +265,7 @@ async fn handle_oauth_callback_internal(
let db = app_state let db = app_state
.db .db
.lock() .lock()
.map_err(|e| format!("Failed to lock database: {}", e))?; .map_err(|e| format!("Failed to lock database: {e}"))?;
db.execute( db.execute(
"INSERT OR REPLACE INTO credentials (id, service, token_hash, encrypted_token, created_at, expires_at) "INSERT OR REPLACE INTO credentials (id, service, token_hash, encrypted_token, created_at, expires_at)
@ -279,7 +279,7 @@ async fn handle_oauth_callback_internal(
expires_at, expires_at,
], ],
) )
.map_err(|e| format!("Failed to store credentials: {}", e))?; .map_err(|e| format!("Failed to store credentials: {e}"))?;
// Log audit event // Log audit event
let audit_details = serde_json::json!({ let audit_details = serde_json::json!({
@ -301,7 +301,7 @@ async fn handle_oauth_callback_internal(
audit_details.to_string(), audit_details.to_string(),
], ],
) )
.map_err(|e| format!("Failed to log audit event: {}", e))?; .map_err(|e| format!("Failed to log audit event: {e}"))?;
Ok(()) Ok(())
} }
@ -319,7 +319,7 @@ pub async fn handle_oauth_callback(
let verifier = { let verifier = {
let mut oauth_state = OAUTH_STATE let mut oauth_state = OAUTH_STATE
.lock() .lock()
.map_err(|e| format!("Failed to lock OAuth state: {}", e))?; .map_err(|e| format!("Failed to lock OAuth state: {e}"))?;
oauth_state oauth_state
.remove(&state_key) .remove(&state_key)
.map(|(_svc, ver)| ver) .map(|(_svc, ver)| ver)
@ -520,7 +520,7 @@ pub async fn authenticate_with_webview(
if let Some(existing_label) = app_state if let Some(existing_label) = app_state
.integration_webviews .integration_webviews
.lock() .lock()
.map_err(|e| format!("Failed to lock webviews: {}", e))? .map_err(|e| format!("Failed to lock webviews: {e}"))?
.get(&service) .get(&service)
{ {
if app_handle.get_webview_window(existing_label).is_some() { if app_handle.get_webview_window(existing_label).is_some() {
@ -545,7 +545,7 @@ pub async fn authenticate_with_webview(
app_state app_state
.integration_webviews .integration_webviews
.lock() .lock()
.map_err(|e| format!("Failed to lock webviews: {}", e))? .map_err(|e| format!("Failed to lock webviews: {e}"))?
.insert(service.clone(), webview_id.clone()); .insert(service.clone(), webview_id.clone());
Ok(WebviewAuthResponse { Ok(WebviewAuthResponse {
@ -582,8 +582,8 @@ pub async fn extract_cookies_from_webview(
} }
// Encrypt and store cookies in database // Encrypt and store cookies in database
let cookies_json = serde_json::to_string(&cookies) let cookies_json =
.map_err(|e| format!("Failed to serialize cookies: {}", e))?; serde_json::to_string(&cookies).map_err(|e| format!("Failed to serialize cookies: {e}"))?;
let encrypted_cookies = crate::integrations::auth::encrypt_token(&cookies_json)?; let encrypted_cookies = crate::integrations::auth::encrypt_token(&cookies_json)?;
let token_hash = { let token_hash = {
@ -597,7 +597,7 @@ pub async fn extract_cookies_from_webview(
let db = app_state let db = app_state
.db .db
.lock() .lock()
.map_err(|e| format!("Failed to lock database: {}", e))?; .map_err(|e| format!("Failed to lock database: {e}"))?;
db.execute( db.execute(
"INSERT OR REPLACE INTO credentials (id, service, token_hash, encrypted_token, created_at, expires_at) "INSERT OR REPLACE INTO credentials (id, service, token_hash, encrypted_token, created_at, expires_at)
@ -611,13 +611,13 @@ pub async fn extract_cookies_from_webview(
None::<String>, // Cookies don't have explicit expiry None::<String>, // Cookies don't have explicit expiry
], ],
) )
.map_err(|e| format!("Failed to store cookies: {}", e))?; .map_err(|e| format!("Failed to store cookies: {e}"))?;
// Close the webview window // Close the webview window
if let Some(webview) = app_handle.get_webview_window(&webview_id) { if let Some(webview) = app_handle.get_webview_window(&webview_id) {
webview webview
.close() .close()
.map_err(|e| format!("Failed to close webview: {}", e))?; .map_err(|e| format!("Failed to close webview: {e}"))?;
} }
Ok(ConnectionResult { Ok(ConnectionResult {
@ -698,7 +698,7 @@ pub async fn save_manual_token(
let db = app_state let db = app_state
.db .db
.lock() .lock()
.map_err(|e| format!("Failed to lock database: {}", e))?; .map_err(|e| format!("Failed to lock database: {e}"))?;
db.execute( db.execute(
"INSERT OR REPLACE INTO credentials (id, service, token_hash, encrypted_token, created_at, expires_at) "INSERT OR REPLACE INTO credentials (id, service, token_hash, encrypted_token, created_at, expires_at)
@ -712,7 +712,7 @@ pub async fn save_manual_token(
None::<String>, None::<String>,
], ],
) )
.map_err(|e| format!("Failed to store token: {}", e))?; .map_err(|e| format!("Failed to store token: {e}"))?;
// Log audit event // Log audit event
db.execute( db.execute(
@ -732,7 +732,7 @@ pub async fn save_manual_token(
.to_string(), .to_string(),
], ],
) )
.map_err(|e| format!("Failed to log audit event: {}", e))?; .map_err(|e| format!("Failed to log audit event: {e}"))?;
Ok(ConnectionResult { Ok(ConnectionResult {
success: true, success: true,
@ -757,7 +757,7 @@ pub async fn get_fresh_cookies_from_webview(
let webviews = app_state let webviews = app_state
.integration_webviews .integration_webviews
.lock() .lock()
.map_err(|e| format!("Failed to lock webviews: {}", e))?; .map_err(|e| format!("Failed to lock webviews: {e}"))?;
match webviews.get(service) { match webviews.get(service) {
Some(label) => label.clone(), Some(label) => label.clone(),
@ -773,7 +773,7 @@ pub async fn get_fresh_cookies_from_webview(
app_state app_state
.integration_webviews .integration_webviews
.lock() .lock()
.map_err(|e| format!("Failed to lock webviews: {}", e))? .map_err(|e| format!("Failed to lock webviews: {e}"))?
.remove(service); .remove(service);
return Ok(None); return Ok(None);
} }
@ -814,7 +814,7 @@ pub async fn save_integration_config(
let db = app_state let db = app_state
.db .db
.lock() .lock()
.map_err(|e| format!("Failed to lock database: {}", e))?; .map_err(|e| format!("Failed to lock database: {e}"))?;
db.execute( db.execute(
"INSERT OR REPLACE INTO integration_config "INSERT OR REPLACE INTO integration_config
@ -829,7 +829,7 @@ pub async fn save_integration_config(
config.space_key, config.space_key,
], ],
) )
.map_err(|e| format!("Failed to save integration config: {}", e))?; .map_err(|e| format!("Failed to save integration config: {e}"))?;
Ok(()) Ok(())
} }
@ -843,11 +843,11 @@ pub async fn get_integration_config(
let db = app_state let db = app_state
.db .db
.lock() .lock()
.map_err(|e| format!("Failed to lock database: {}", e))?; .map_err(|e| format!("Failed to lock database: {e}"))?;
let mut stmt = db let mut stmt = db
.prepare("SELECT service, base_url, username, project_name, space_key FROM integration_config WHERE service = ?1") .prepare("SELECT service, base_url, username, project_name, space_key FROM integration_config WHERE service = ?1")
.map_err(|e| format!("Failed to prepare query: {}", e))?; .map_err(|e| format!("Failed to prepare query: {e}"))?;
let config = stmt let config = stmt
.query_row([&service], |row| { .query_row([&service], |row| {
@ -860,7 +860,7 @@ pub async fn get_integration_config(
}) })
}) })
.optional() .optional()
.map_err(|e| format!("Failed to query integration config: {}", e))?; .map_err(|e| format!("Failed to query integration config: {e}"))?;
Ok(config) Ok(config)
} }
@ -873,13 +873,13 @@ pub async fn get_all_integration_configs(
let db = app_state let db = app_state
.db .db
.lock() .lock()
.map_err(|e| format!("Failed to lock database: {}", e))?; .map_err(|e| format!("Failed to lock database: {e}"))?;
let mut stmt = db let mut stmt = db
.prepare( .prepare(
"SELECT service, base_url, username, project_name, space_key FROM integration_config", "SELECT service, base_url, username, project_name, space_key FROM integration_config",
) )
.map_err(|e| format!("Failed to prepare query: {}", e))?; .map_err(|e| format!("Failed to prepare query: {e}"))?;
let configs = stmt let configs = stmt
.query_map([], |row| { .query_map([], |row| {
@ -891,9 +891,9 @@ pub async fn get_all_integration_configs(
space_key: row.get(4)?, space_key: row.get(4)?,
}) })
}) })
.map_err(|e| format!("Failed to query integration configs: {}", e))? .map_err(|e| format!("Failed to query integration configs: {e}"))?
.collect::<Result<Vec<_>, _>>() .collect::<Result<Vec<_>, _>>()
.map_err(|e| format!("Failed to collect integration configs: {}", e))?; .map_err(|e| format!("Failed to collect integration configs: {e}"))?;
Ok(configs) Ok(configs)
} }

View File

@ -162,13 +162,13 @@ pub fn run_migrations(conn: &Connection) -> anyhow::Result<()> {
// FTS5 virtual table creation can be skipped if FTS5 is not compiled in // FTS5 virtual table creation can be skipped if FTS5 is not compiled in
if let Err(e) = conn.execute_batch(sql) { if let Err(e) = conn.execute_batch(sql) {
if name.contains("fts") { if name.contains("fts") {
tracing::warn!("FTS5 not available, skipping: {}", e); tracing::warn!("FTS5 not available, skipping: {e}");
} else { } else {
return Err(e.into()); return Err(e.into());
} }
} }
conn.execute("INSERT INTO _migrations (name) VALUES (?1)", [name])?; conn.execute("INSERT INTO _migrations (name) VALUES (?1)", [name])?;
tracing::info!("Applied migration: {}", name); tracing::info!("Applied migration: {name}");
} }
} }

View File

@ -88,7 +88,7 @@ pub async fn exchange_code(
.form(&params) .form(&params)
.send() .send()
.await .await
.map_err(|e| format!("Failed to send token exchange request: {}", e))?; .map_err(|e| format!("Failed to send token exchange request: {e}"))?;
if !resp.status().is_success() { if !resp.status().is_success() {
return Err(format!( return Err(format!(
@ -101,7 +101,7 @@ pub async fn exchange_code(
let body: serde_json::Value = resp let body: serde_json::Value = resp
.json() .json()
.await .await
.map_err(|e| format!("Failed to parse token response: {}", e))?; .map_err(|e| format!("Failed to parse token response: {e}"))?;
let access_token = body["access_token"] let access_token = body["access_token"]
.as_str() .as_str()
@ -208,7 +208,7 @@ pub fn encrypt_token(token: &str) -> Result<String, String> {
// Encrypt // Encrypt
let ciphertext = cipher let ciphertext = cipher
.encrypt(nonce, token.as_bytes()) .encrypt(nonce, token.as_bytes())
.map_err(|e| format!("Encryption failed: {}", e))?; .map_err(|e| format!("Encryption failed: {e}"))?;
// Prepend nonce to ciphertext // Prepend nonce to ciphertext
let mut result = nonce_bytes.to_vec(); let mut result = nonce_bytes.to_vec();
@ -232,7 +232,7 @@ pub fn decrypt_token(encrypted: &str) -> Result<String, String> {
use base64::Engine; use base64::Engine;
let data = STANDARD let data = STANDARD
.decode(encrypted) .decode(encrypted)
.map_err(|e| format!("Base64 decode failed: {}", e))?; .map_err(|e| format!("Base64 decode failed: {e}"))?;
if data.len() < 12 { if data.len() < 12 {
return Err("Invalid encrypted data: too short".to_string()); return Err("Invalid encrypted data: too short".to_string());
@ -256,9 +256,9 @@ pub fn decrypt_token(encrypted: &str) -> Result<String, String> {
// Decrypt // Decrypt
let plaintext = cipher let plaintext = cipher
.decrypt(nonce, ciphertext) .decrypt(nonce, ciphertext)
.map_err(|e| format!("Decryption failed: {}", e))?; .map_err(|e| format!("Decryption failed: {e}"))?;
String::from_utf8(plaintext).map_err(|e| format!("Invalid UTF-8: {}", e)) String::from_utf8(plaintext).map_err(|e| format!("Invalid UTF-8: {e}"))
} }
#[cfg(test)] #[cfg(test)]

View File

@ -32,7 +32,7 @@ pub async fn test_connection(config: &AzureDevOpsConfig) -> Result<ConnectionRes
.bearer_auth(&config.access_token) .bearer_auth(&config.access_token)
.send() .send()
.await .await
.map_err(|e| format!("Connection failed: {}", e))?; .map_err(|e| format!("Connection failed: {e}"))?;
if resp.status().is_success() { if resp.status().is_success() {
Ok(ConnectionResult { Ok(ConnectionResult {
@ -74,7 +74,7 @@ pub async fn search_work_items(
.json(&body) .json(&body)
.send() .send()
.await .await
.map_err(|e| format!("WIQL query failed: {}", e))?; .map_err(|e| format!("WIQL query failed: {e}"))?;
if !resp.status().is_success() { if !resp.status().is_success() {
return Err(format!( return Err(format!(
@ -87,7 +87,7 @@ pub async fn search_work_items(
let wiql_result: serde_json::Value = resp let wiql_result: serde_json::Value = resp
.json() .json()
.await .await
.map_err(|e| format!("Failed to parse WIQL response: {}", e))?; .map_err(|e| format!("Failed to parse WIQL response: {e}"))?;
let work_item_refs = wiql_result["workItems"] let work_item_refs = wiql_result["workItems"]
.as_array() .as_array()
@ -119,7 +119,7 @@ pub async fn search_work_items(
.bearer_auth(&config.access_token) .bearer_auth(&config.access_token)
.send() .send()
.await .await
.map_err(|e| format!("Failed to fetch work item details: {}", e))?; .map_err(|e| format!("Failed to fetch work item details: {e}"))?;
if !detail_resp.status().is_success() { if !detail_resp.status().is_success() {
return Err(format!( return Err(format!(
@ -131,7 +131,7 @@ pub async fn search_work_items(
let details: serde_json::Value = detail_resp let details: serde_json::Value = detail_resp
.json() .json()
.await .await
.map_err(|e| format!("Failed to parse work item details: {}", e))?; .map_err(|e| format!("Failed to parse work item details: {e}"))?;
let work_items = details["value"] let work_items = details["value"]
.as_array() .as_array()
@ -199,7 +199,7 @@ pub async fn create_work_item(
.json(&operations) .json(&operations)
.send() .send()
.await .await
.map_err(|e| format!("Failed to create work item: {}", e))?; .map_err(|e| format!("Failed to create work item: {e}"))?;
if !resp.status().is_success() { if !resp.status().is_success() {
return Err(format!( return Err(format!(
@ -212,7 +212,7 @@ pub async fn create_work_item(
let result: serde_json::Value = resp let result: serde_json::Value = resp
.json() .json()
.await .await
.map_err(|e| format!("Failed to parse response: {}", e))?; .map_err(|e| format!("Failed to parse response: {e}"))?;
let work_item_id = result["id"].as_i64().unwrap_or(0); let work_item_id = result["id"].as_i64().unwrap_or(0);
let work_item_url = format!( let work_item_url = format!(
@ -223,7 +223,7 @@ pub async fn create_work_item(
Ok(TicketResult { Ok(TicketResult {
id: work_item_id.to_string(), id: work_item_id.to_string(),
ticket_number: format!("#{}", work_item_id), ticket_number: format!("#{work_item_id}"),
url: work_item_url, url: work_item_url,
}) })
} }
@ -246,7 +246,7 @@ pub async fn get_work_item(
.bearer_auth(&config.access_token) .bearer_auth(&config.access_token)
.send() .send()
.await .await
.map_err(|e| format!("Failed to get work item: {}", e))?; .map_err(|e| format!("Failed to get work item: {e}"))?;
if !resp.status().is_success() { if !resp.status().is_success() {
return Err(format!( return Err(format!(
@ -259,7 +259,7 @@ pub async fn get_work_item(
let result: serde_json::Value = resp let result: serde_json::Value = resp
.json() .json()
.await .await
.map_err(|e| format!("Failed to parse response: {}", e))?; .map_err(|e| format!("Failed to parse response: {e}"))?;
Ok(WorkItem { Ok(WorkItem {
id: result["id"] id: result["id"]
@ -305,7 +305,7 @@ pub async fn update_work_item(
.json(&updates) .json(&updates)
.send() .send()
.await .await
.map_err(|e| format!("Failed to update work item: {}", e))?; .map_err(|e| format!("Failed to update work item: {e}"))?;
if !resp.status().is_success() { if !resp.status().is_success() {
return Err(format!( return Err(format!(
@ -318,7 +318,7 @@ pub async fn update_work_item(
let result: serde_json::Value = resp let result: serde_json::Value = resp
.json() .json()
.await .await
.map_err(|e| format!("Failed to parse response: {}", e))?; .map_err(|e| format!("Failed to parse response: {e}"))?;
let updated_work_item_id = result["id"].as_i64().unwrap_or(work_item_id); let updated_work_item_id = result["id"].as_i64().unwrap_or(work_item_id);
let work_item_url = format!( let work_item_url = format!(
@ -329,7 +329,7 @@ pub async fn update_work_item(
Ok(TicketResult { Ok(TicketResult {
id: updated_work_item_id.to_string(), id: updated_work_item_id.to_string(),
ticket_number: format!("#{}", updated_work_item_id), ticket_number: format!("#{updated_work_item_id}"),
url: work_item_url, url: work_item_url,
}) })
} }

View File

@ -35,7 +35,7 @@ pub async fn test_connection(config: &ConfluenceConfig) -> Result<ConnectionResu
.bearer_auth(&config.access_token) .bearer_auth(&config.access_token)
.send() .send()
.await .await
.map_err(|e| format!("Connection failed: {}", e))?; .map_err(|e| format!("Connection failed: {e}"))?;
if resp.status().is_success() { if resp.status().is_success() {
Ok(ConnectionResult { Ok(ConnectionResult {
@ -61,7 +61,7 @@ pub async fn list_spaces(config: &ConfluenceConfig) -> Result<Vec<Space>, String
.query(&[("limit", "100")]) .query(&[("limit", "100")])
.send() .send()
.await .await
.map_err(|e| format!("Failed to list spaces: {}", e))?; .map_err(|e| format!("Failed to list spaces: {e}"))?;
if !resp.status().is_success() { if !resp.status().is_success() {
return Err(format!( return Err(format!(
@ -74,7 +74,7 @@ pub async fn list_spaces(config: &ConfluenceConfig) -> Result<Vec<Space>, String
let body: serde_json::Value = resp let body: serde_json::Value = resp
.json() .json()
.await .await
.map_err(|e| format!("Failed to parse response: {}", e))?; .map_err(|e| format!("Failed to parse response: {e}"))?;
let spaces = body["results"] let spaces = body["results"]
.as_array() .as_array()
@ -114,7 +114,7 @@ pub async fn search_pages(
.query(&[("cql", &cql), ("limit", &"50".to_string())]) .query(&[("cql", &cql), ("limit", &"50".to_string())])
.send() .send()
.await .await
.map_err(|e| format!("Search failed: {}", e))?; .map_err(|e| format!("Search failed: {e}"))?;
if !resp.status().is_success() { if !resp.status().is_success() {
return Err(format!( return Err(format!(
@ -127,7 +127,7 @@ pub async fn search_pages(
let body: serde_json::Value = resp let body: serde_json::Value = resp
.json() .json()
.await .await
.map_err(|e| format!("Failed to parse response: {}", e))?; .map_err(|e| format!("Failed to parse response: {e}"))?;
let pages = body["results"] let pages = body["results"]
.as_array() .as_array()
@ -182,7 +182,7 @@ pub async fn publish_page(
.json(&body) .json(&body)
.send() .send()
.await .await
.map_err(|e| format!("Failed to publish page: {}", e))?; .map_err(|e| format!("Failed to publish page: {e}"))?;
if !resp.status().is_success() { if !resp.status().is_success() {
return Err(format!( return Err(format!(
@ -195,7 +195,7 @@ pub async fn publish_page(
let result: serde_json::Value = resp let result: serde_json::Value = resp
.json() .json()
.await .await
.map_err(|e| format!("Failed to parse response: {}", e))?; .map_err(|e| format!("Failed to parse response: {e}"))?;
let page_id = result["id"].as_str().unwrap_or(""); let page_id = result["id"].as_str().unwrap_or("");
let page_url = format!( let page_url = format!(
@ -245,7 +245,7 @@ pub async fn update_page(
.json(&body) .json(&body)
.send() .send()
.await .await
.map_err(|e| format!("Failed to update page: {}", e))?; .map_err(|e| format!("Failed to update page: {e}"))?;
if !resp.status().is_success() { if !resp.status().is_success() {
return Err(format!( return Err(format!(
@ -258,7 +258,7 @@ pub async fn update_page(
let result: serde_json::Value = resp let result: serde_json::Value = resp
.json() .json()
.await .await
.map_err(|e| format!("Failed to parse response: {}", e))?; .map_err(|e| format!("Failed to parse response: {e}"))?;
let updated_page_id = result["id"].as_str().unwrap_or(page_id); let updated_page_id = result["id"].as_str().unwrap_or(page_id);
let page_url = format!( let page_url = format!(

View File

@ -34,7 +34,7 @@ pub async fn test_connection(config: &ServiceNowConfig) -> Result<ConnectionResu
.query(&[("sysparm_limit", "1")]) .query(&[("sysparm_limit", "1")])
.send() .send()
.await .await
.map_err(|e| format!("Connection failed: {}", e))?; .map_err(|e| format!("Connection failed: {e}"))?;
if resp.status().is_success() { if resp.status().is_success() {
Ok(ConnectionResult { Ok(ConnectionResult {
@ -60,7 +60,7 @@ pub async fn search_incidents(
config.instance_url.trim_end_matches('/') config.instance_url.trim_end_matches('/')
); );
let sysparm_query = format!("short_descriptionLIKE{}", query); let sysparm_query = format!("short_descriptionLIKE{query}");
let resp = client let resp = client
.get(&url) .get(&url)
@ -71,7 +71,7 @@ pub async fn search_incidents(
]) ])
.send() .send()
.await .await
.map_err(|e| format!("Search failed: {}", e))?; .map_err(|e| format!("Search failed: {e}"))?;
if !resp.status().is_success() { if !resp.status().is_success() {
return Err(format!( return Err(format!(
@ -84,7 +84,7 @@ pub async fn search_incidents(
let body: serde_json::Value = resp let body: serde_json::Value = resp
.json() .json()
.await .await
.map_err(|e| format!("Failed to parse response: {}", e))?; .map_err(|e| format!("Failed to parse response: {e}"))?;
let incidents = body["result"] let incidents = body["result"]
.as_array() .as_array()
@ -134,7 +134,7 @@ pub async fn create_incident(
.json(&body) .json(&body)
.send() .send()
.await .await
.map_err(|e| format!("Failed to create incident: {}", e))?; .map_err(|e| format!("Failed to create incident: {e}"))?;
if !resp.status().is_success() { if !resp.status().is_success() {
return Err(format!( return Err(format!(
@ -147,7 +147,7 @@ pub async fn create_incident(
let result: serde_json::Value = resp let result: serde_json::Value = resp
.json() .json()
.await .await
.map_err(|e| format!("Failed to parse response: {}", e))?; .map_err(|e| format!("Failed to parse response: {e}"))?;
let incident_number = result["result"]["number"].as_str().unwrap_or(""); let incident_number = result["result"]["number"].as_str().unwrap_or("");
let sys_id = result["result"]["sys_id"].as_str().unwrap_or(""); let sys_id = result["result"]["sys_id"].as_str().unwrap_or("");
@ -198,13 +198,13 @@ pub async fn get_incident(
.basic_auth(&config.username, Some(&config.password)); .basic_auth(&config.username, Some(&config.password));
if use_query { if use_query {
request = request.query(&[("sysparm_query", &format!("number={}", incident_id))]); request = request.query(&[("sysparm_query", &format!("number={incident_id}"))]);
} }
let resp = request let resp = request
.send() .send()
.await .await
.map_err(|e| format!("Failed to get incident: {}", e))?; .map_err(|e| format!("Failed to get incident: {e}"))?;
if !resp.status().is_success() { if !resp.status().is_success() {
return Err(format!( return Err(format!(
@ -217,7 +217,7 @@ pub async fn get_incident(
let body: serde_json::Value = resp let body: serde_json::Value = resp
.json() .json()
.await .await
.map_err(|e| format!("Failed to parse response: {}", e))?; .map_err(|e| format!("Failed to parse response: {e}"))?;
let incident_data = if use_query { let incident_data = if use_query {
// Query response has "result" array // Query response has "result" array
@ -273,7 +273,7 @@ pub async fn update_incident(
.json(&updates) .json(&updates)
.send() .send()
.await .await
.map_err(|e| format!("Failed to update incident: {}", e))?; .map_err(|e| format!("Failed to update incident: {e}"))?;
if !resp.status().is_success() { if !resp.status().is_success() {
return Err(format!( return Err(format!(
@ -286,7 +286,7 @@ pub async fn update_incident(
let result: serde_json::Value = resp let result: serde_json::Value = resp
.json() .json()
.await .await
.map_err(|e| format!("Failed to parse response: {}", e))?; .map_err(|e| format!("Failed to parse response: {e}"))?;
let incident_number = result["result"]["number"].as_str().unwrap_or(""); let incident_number = result["result"]["number"].as_str().unwrap_or("");
let updated_sys_id = result["result"]["sys_id"].as_str().unwrap_or(sys_id); let updated_sys_id = result["result"]["sys_id"].as_str().unwrap_or(sys_id);

View File

@ -32,7 +32,7 @@ pub async fn authenticate_with_webview(
format!("{}/_signin", base_url.trim_end_matches('/')) format!("{}/_signin", base_url.trim_end_matches('/'))
} }
"servicenow" => format!("{}/login.do", base_url.trim_end_matches('/')), "servicenow" => format!("{}/login.do", base_url.trim_end_matches('/')),
_ => return Err(format!("Unknown service: {}", service)), _ => return Err(format!("Unknown service: {service}")),
}; };
tracing::info!( tracing::info!(
@ -46,11 +46,7 @@ pub async fn authenticate_with_webview(
let webview = WebviewWindowBuilder::new( let webview = WebviewWindowBuilder::new(
&app_handle, &app_handle,
&webview_label, &webview_label,
WebviewUrl::External( WebviewUrl::External(login_url.parse().map_err(|e| format!("Invalid URL: {e}"))?),
login_url
.parse()
.map_err(|e| format!("Invalid URL: {}", e))?,
),
) )
.title(format!("{} Browser (TFTSR)", service)) .title(format!("{} Browser (TFTSR)", service))
.inner_size(1000.0, 800.0) .inner_size(1000.0, 800.0)
@ -60,12 +56,12 @@ pub async fn authenticate_with_webview(
.focused(true) .focused(true)
.visible(true) .visible(true)
.build() .build()
.map_err(|e| format!("Failed to create webview: {}", e))?; .map_err(|e| format!("Failed to create webview: {e}"))?;
// Focus the window // Focus the window
webview webview
.set_focus() .set_focus()
.map_err(|e| tracing::warn!("Failed to focus webview: {}", e)) .map_err(|e| tracing::warn!("Failed to focus webview: {e}"))
.ok(); .ok();
// Wait for user to complete login // Wait for user to complete login
@ -147,7 +143,7 @@ pub async fn extract_cookies_via_ipc<R: tauri::Runtime>(
match serde_json::from_str::<serde_json::Value>(payload_str) { match serde_json::from_str::<serde_json::Value>(payload_str) {
Ok(payload) => { Ok(payload) => {
if let Some(error_msg) = payload.get("error").and_then(|e| e.as_str()) { if let Some(error_msg) = payload.get("error").and_then(|e| e.as_str()) {
let _ = tx.try_send(Err(format!("JavaScript error: {}", error_msg))); let _ = tx.try_send(Err(format!("JavaScript error: {error_msg}")));
return; return;
} }
@ -158,8 +154,8 @@ pub async fn extract_cookies_via_ipc<R: tauri::Runtime>(
let _ = tx.try_send(Ok(cookies)); let _ = tx.try_send(Ok(cookies));
} }
Err(e) => { Err(e) => {
tracing::error!("Failed to parse cookies: {}", e); tracing::error!("Failed to parse cookies: {e}");
let _ = tx.try_send(Err(format!("Failed to parse cookies: {}", e))); let _ = tx.try_send(Err(format!("Failed to parse cookies: {e}")));
} }
} }
} else { } else {
@ -167,8 +163,8 @@ pub async fn extract_cookies_via_ipc<R: tauri::Runtime>(
} }
} }
Err(e) => { Err(e) => {
tracing::error!("Failed to parse event payload: {}", e); tracing::error!("Failed to parse event payload: {e}");
let _ = tx.try_send(Err(format!("Failed to parse event payload: {}", e))); let _ = tx.try_send(Err(format!("Failed to parse event payload: {e}")));
} }
} }
}); });
@ -176,7 +172,7 @@ pub async fn extract_cookies_via_ipc<R: tauri::Runtime>(
// Inject the script into the webview // Inject the script into the webview
webview_window webview_window
.eval(cookie_extraction_script) .eval(cookie_extraction_script)
.map_err(|e| format!("Failed to inject cookie extraction script: {}", e))?; .map_err(|e| format!("Failed to inject cookie extraction script: {e}"))?;
tracing::info!("Cookie extraction script injected, waiting for response..."); tracing::info!("Cookie extraction script injected, waiting for response...");