From 9609880cff679f50c2ba4cf9c38257528e35d3f5 Mon Sep 17 00:00:00 2001 From: Per Stark Date: Wed, 27 May 2026 13:56:32 +0200 Subject: [PATCH] fix: revoke_api_key sets NONE, remove unused bind, lowercase error msgs - fix bug where revoke_api_key set literal 'test_string_nullish' instead of NONE - remove unused table_name bind in update_timezone - lowercase ~16 error messages across 4 crates --- common/src/storage/types/analytics.rs | 8 ++++---- common/src/storage/types/conversation.rs | 4 ++-- common/src/storage/types/scratchpad.rs | 2 +- common/src/storage/types/system_settings.rs | 4 ++-- common/src/storage/types/user.rs | 7 +++---- html-router/src/routes/chat/chat_handlers.rs | 6 +++--- html-router/src/routes/index/handlers.rs | 2 +- html-router/src/routes/knowledge/handlers.rs | 2 +- ingestion-pipeline/src/utils/url_text_retrieval.rs | 2 +- 9 files changed, 18 insertions(+), 19 deletions(-) diff --git a/common/src/storage/types/analytics.rs b/common/src/storage/types/analytics.rs index f34a789..29da3ab 100644 --- a/common/src/storage/types/analytics.rs +++ b/common/src/storage/types/analytics.rs @@ -34,7 +34,7 @@ impl Analytics { let stored: Option = db.store_item(created_analytics).await?; return stored.ok_or(AppError::Validation( - "Failed to initialize analytics".into(), +"failed to initialize analytics".into(), )); } @@ -44,7 +44,7 @@ impl Analytics { } pub async fn get_current(db: &SurrealDbClient) -> Result { let analytics: Option = db.get_item("current").await?; - analytics.ok_or(AppError::NotFound("Analytics not found".into())) + analytics.ok_or(AppError::NotFound("analytics not found".into())) } pub async fn increment_visitors(db: &SurrealDbClient) -> Result { @@ -54,7 +54,7 @@ impl Analytics { .await? .take(0)?; - updated.ok_or(AppError::Validation("Failed to update analytics".into())) + updated.ok_or(AppError::Validation("failed to update analytics".into())) } pub async fn increment_page_loads(db: &SurrealDbClient) -> Result { @@ -64,7 +64,7 @@ impl Analytics { .await? .take(0)?; - updated.ok_or(AppError::Validation("Failed to update analytics".into())) + updated.ok_or(AppError::Validation("failed to update analytics".into())) } pub async fn get_users_amount(db: &SurrealDbClient) -> Result { diff --git a/common/src/storage/types/conversation.rs b/common/src/storage/types/conversation.rs index b27a56c..c0b3bb1 100644 --- a/common/src/storage/types/conversation.rs +++ b/common/src/storage/types/conversation.rs @@ -79,7 +79,7 @@ impl Conversation { let conversation: Conversation = db .get_item(conversation_id) .await? - .ok_or_else(|| AppError::NotFound("Conversation not found".to_string()))?; + .ok_or_else(|| AppError::NotFound("conversation not found".to_string()))?; if conversation.user_id != user_id { return Err(AppError::Auth( @@ -105,7 +105,7 @@ impl Conversation { // First verify ownership by getting conversation user_id let conversation: Option = db.get_item(id).await?; let conversation = - conversation.ok_or_else(|| AppError::NotFound("Conversation not found".to_string()))?; + conversation.ok_or_else(|| AppError::NotFound("conversation not found".to_string()))?; if conversation.user_id != user_id { return Err(AppError::Auth( diff --git a/common/src/storage/types/scratchpad.rs b/common/src/storage/types/scratchpad.rs index 1645968..9d966f0 100644 --- a/common/src/storage/types/scratchpad.rs +++ b/common/src/storage/types/scratchpad.rs @@ -78,7 +78,7 @@ impl Scratchpad { let scratchpad: Option = db.get_item(id).await?; let scratchpad = - scratchpad.ok_or_else(|| AppError::NotFound("Scratchpad not found".to_string()))?; + scratchpad.ok_or_else(|| AppError::NotFound("scratchpad not found".to_string()))?; if scratchpad.user_id != user_id { return Err(AppError::Auth( diff --git a/common/src/storage/types/system_settings.rs b/common/src/storage/types/system_settings.rs index 65a1c28..1e11224 100644 --- a/common/src/storage/types/system_settings.rs +++ b/common/src/storage/types/system_settings.rs @@ -36,7 +36,7 @@ impl StoredObject for SystemSettings { impl SystemSettings { pub async fn get_current(db: &SurrealDbClient) -> Result { let settings: Option = db.get_item("current").await?; - settings.ok_or(AppError::NotFound("System settings not found".into())) + settings.ok_or(AppError::NotFound("system settings not found".into())) } pub async fn update(db: &SurrealDbClient, changes: Self) -> Result { @@ -49,7 +49,7 @@ impl SystemSettings { .take(0)?; updated.ok_or(AppError::Validation( - "Something went wrong updating the settings".into(), + "something went wrong updating the settings".into(), )) } diff --git a/common/src/storage/types/user.rs b/common/src/storage/types/user.rs index 8cc9251..1f8f3bb 100644 --- a/common/src/storage/types/user.rs +++ b/common/src/storage/types/user.rs @@ -371,7 +371,7 @@ impl User { .client .query( "UPDATE type::thing('user', $id) - SET api_key = test_string_nullish + SET api_key = NONE RETURN AFTER", ) .bind(("id", id.to_owned())) @@ -532,7 +532,6 @@ impl User { db: &SurrealDbClient, ) -> Result<(), AppError> { db.query("UPDATE type::thing('user', $user_id) SET timezone = $timezone") - .bind(("table_name", Self::table_name())) .bind(("user_id", user_id.to_string())) .bind(("timezone", timezone.to_string())) .await?; @@ -579,7 +578,7 @@ impl User { let entity: KnowledgeEntity = db .get_item(id) .await? - .ok_or_else(|| AppError::NotFound("Entity not found".into()))?; + .ok_or_else(|| AppError::NotFound("entity not found".into()))?; if entity.user_id != user_id { return Err(AppError::Auth("Access denied".into())); @@ -596,7 +595,7 @@ impl User { let text_content: TextContent = db .get_item(id) .await? - .ok_or_else(|| AppError::NotFound("Content not found".into()))?; + .ok_or_else(|| AppError::NotFound("content not found".into()))?; if text_content.user_id != user_id { return Err(AppError::Auth("Access denied".into())); diff --git a/html-router/src/routes/chat/chat_handlers.rs b/html-router/src/routes/chat/chat_handlers.rs index aca01b9..4d8a752 100644 --- a/html-router/src/routes/chat/chat_handlers.rs +++ b/html-router/src/routes/chat/chat_handlers.rs @@ -148,7 +148,7 @@ pub async fn new_user_message( .db .get_item(&conversation_id) .await? - .ok_or_else(|| AppError::NotFound("Conversation was not found".into()))?; + .ok_or_else(|| AppError::NotFound("conversation was not found".into()))?; if conversation.user_id != user.id { return Ok(TemplateResponse::unauthorized().into_response()); @@ -235,7 +235,7 @@ pub async fn show_conversation_editing_title( .db .get_item(&conversation_id) .await? - .ok_or_else(|| AppError::NotFound("Conversation not found".to_string()))?; + .ok_or_else(|| AppError::NotFound("conversation not found".to_string()))?; if conversation.user_id != user.id { return Ok(TemplateResponse::unauthorized().into_response()); @@ -277,7 +277,7 @@ pub async fn delete_conversation( .db .get_item(&conversation_id) .await? - .ok_or_else(|| AppError::NotFound("Conversation not found".to_string()))?; + .ok_or_else(|| AppError::NotFound("conversation not found".to_string()))?; if conversation.user_id != user.id { return Ok(TemplateResponse::unauthorized().into_response()); diff --git a/html-router/src/routes/index/handlers.rs b/html-router/src/routes/index/handlers.rs index 60de178..eed1791 100644 --- a/html-router/src/routes/index/handlers.rs +++ b/html-router/src/routes/index/handlers.rs @@ -113,7 +113,7 @@ async fn get_and_validate_text_content( .db .get_item::(id) .await? - .ok_or_else(|| AppError::NotFound("Item was not found".to_string()))?; + .ok_or_else(|| AppError::NotFound("item was not found".to_string()))?; if text_content.user_id != user.id { return Err(AppError::Auth( diff --git a/html-router/src/routes/knowledge/handlers.rs b/html-router/src/routes/knowledge/handlers.rs index 226e983..970ae45 100644 --- a/html-router/src/routes/knowledge/handlers.rs +++ b/html-router/src/routes/knowledge/handlers.rs @@ -173,7 +173,7 @@ pub async fn create_knowledge_entity( ) -> Result { let name = form.name.trim().to_string(); if name.is_empty() { - return Err(AppError::Validation("Name is required".into()).into()); + return Err(AppError::Validation("name is required".into()).into()); } let description = form.description.trim().to_string(); diff --git a/ingestion-pipeline/src/utils/url_text_retrieval.rs b/ingestion-pipeline/src/utils/url_text_retrieval.rs index e399b90..87fee9d 100644 --- a/ingestion-pipeline/src/utils/url_text_retrieval.rs +++ b/ingestion-pipeline/src/utils/url_text_retrieval.rs @@ -75,7 +75,7 @@ pub async fn extract_text_from_url( } let parsed_url = - url::Url::parse(url).map_err(|_| AppError::Validation("Invalid URL".to_string()))?; + url::Url::parse(url).map_err(|_| AppError::Validation("invalid URL".to_string()))?; let domain = ensure_ingestion_url_allowed(&parsed_url)?; let timestamp = Utc::now().format("%Y%m%d%H%M%S");