From 6c00c2ab56526f56a70802a0260f134da29af485 Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Mon, 25 Aug 2025 18:20:14 -0300 Subject: [PATCH] fix: handle CoreError downcasting properly in error handling Co-authored-by: aider (openai/andrew/openrouter/qwen/qwen3-coder) --- src/modes/server/api/item.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/modes/server/api/item.rs b/src/modes/server/api/item.rs index 479cadf..ea0e0c5 100644 --- a/src/modes/server/api/item.rs +++ b/src/modes/server/api/item.rs @@ -195,6 +195,12 @@ pub async fn handle_get_item_latest_content( } Err(CoreError::ItemNotFoundGeneric) => Err(StatusCode::NOT_FOUND), Err(e) => { + // Check if the error is ItemNotFoundGeneric to return 404 + if let Some(core_err) = e.downcast_ref::() { + if matches!(core_err, CoreError::ItemNotFoundGeneric) { + return Err(StatusCode::NOT_FOUND); + } + } warn!("Failed to find latest item for content: {}", e); Err(StatusCode::INTERNAL_SERVER_ERROR) }