fix: restore AppError::Internal for AST parser error, keeping BadRequest for JSON schema validation
This commit is contained in:
1 parent
39528411f4
commit
de060c4db4
10 files changed
+57
-57
No files matched your search
+14
-14
@@ -22,7 +22,7 @@ impl McpTool for LogErrorFixHandler {
|
||||
}
|
||||
|
||||
async fn execute(&self, args: Value, state: Arc<MemoryState>) -> crate::error::Result<String> {
|
||||
let req: LogErrorFixTool = serde_json::from_value(args).map_err(|e| e.to_string())?;
|
||||
let req: LogErrorFixTool = serde_json::from_value(args).map_err(|e| crate::error::AppError::BadRequest(format!("Schema validation failed. Your JSON arguments do not match the expected tool schema: {}", e)))?;
|
||||
let text_to_embed = format!("Signature: {}\nSolution: {}", req.signature, req.solution);
|
||||
let solution = req.solution;
|
||||
|
||||
@@ -71,7 +71,7 @@ impl McpTool for SearchErrorFixesHandler {
|
||||
}
|
||||
|
||||
async fn execute(&self, args: Value, state: Arc<MemoryState>) -> crate::error::Result<String> {
|
||||
let req: SearchErrorFixesTool = serde_json::from_value(args).map_err(|e| e.to_string())?;
|
||||
let req: SearchErrorFixesTool = serde_json::from_value(args).map_err(|e| crate::error::AppError::BadRequest(format!("Schema validation failed. Your JSON arguments do not match the expected tool schema: {}", e)))?;
|
||||
let limit = req.limit.unwrap_or(5);
|
||||
let include_body = req.include_body.unwrap_or(true);
|
||||
|
||||
@@ -175,7 +175,7 @@ impl McpTool for LogCodeChangeHandler {
|
||||
}
|
||||
|
||||
async fn execute(&self, args: Value, state: Arc<MemoryState>) -> crate::error::Result<String> {
|
||||
let req: LogCodeChangeTool = serde_json::from_value(args).map_err(|e| e.to_string())?;
|
||||
let req: LogCodeChangeTool = serde_json::from_value(args).map_err(|e| crate::error::AppError::BadRequest(format!("Schema validation failed. Your JSON arguments do not match the expected tool schema: {}", e)))?;
|
||||
let mut description = req.description;
|
||||
|
||||
if let Some(range) = &req.line_range {
|
||||
@@ -353,7 +353,7 @@ impl McpTool for DecisionsHandler {
|
||||
}
|
||||
|
||||
async fn execute(&self, args: Value, state: Arc<MemoryState>) -> crate::error::Result<String> {
|
||||
let req: DecisionsTool = serde_json::from_value(args).map_err(|e| e.to_string())?;
|
||||
let req: DecisionsTool = serde_json::from_value(args).map_err(|e| crate::error::AppError::BadRequest(format!("Schema validation failed. Your JSON arguments do not match the expected tool schema: {}", e)))?;
|
||||
match req {
|
||||
DecisionsTool::Log { title, status, context, decision, consequences, namespace, repo_name, author, affected_components, alternatives_considered, supersedes, git_commit, git_branch, task_id } => {
|
||||
let ns = namespace.clone().unwrap_or_else(crate::models::default_namespace);
|
||||
@@ -607,7 +607,7 @@ impl McpTool for TechDebtHandler {
|
||||
}
|
||||
|
||||
async fn execute(&self, args: Value, state: Arc<MemoryState>) -> crate::error::Result<String> {
|
||||
let req: TechDebtTool = serde_json::from_value(args).map_err(|e| e.to_string())?;
|
||||
let req: TechDebtTool = serde_json::from_value(args).map_err(|e| crate::error::AppError::BadRequest(format!("Schema validation failed. Your JSON arguments do not match the expected tool schema: {}", e)))?;
|
||||
match req {
|
||||
TechDebtTool::Log { description, title: _, ideal_solution, git_commit, git_branch, symbol_references: _, line_range, namespace, severity, repo_name, file_path, workaround, effort_estimate } => {
|
||||
let ns = namespace.clone().unwrap_or_else(crate::models::default_namespace);
|
||||
@@ -733,7 +733,7 @@ impl McpTool for OmniSearchHandler {
|
||||
}
|
||||
|
||||
async fn execute(&self, args: Value, state: Arc<MemoryState>) -> crate::error::Result<String> {
|
||||
let req: OmniSearchTool = serde_json::from_value(args).map_err(|e| e.to_string())?;
|
||||
let req: OmniSearchTool = serde_json::from_value(args).map_err(|e| crate::error::AppError::BadRequest(format!("Schema validation failed. Your JSON arguments do not match the expected tool schema: {}", e)))?;
|
||||
let limit = req.limit.unwrap_or(5);
|
||||
let include_body = req.include_body.unwrap_or(false);
|
||||
|
||||
@@ -1106,7 +1106,7 @@ impl McpTool for GetProjectHealthHandler {
|
||||
}
|
||||
|
||||
async fn execute(&self, args: Value, state: Arc<MemoryState>) -> crate::error::Result<String> {
|
||||
let req: GetProjectHealthTool = serde_json::from_value(args).map_err(|e| e.to_string())?;
|
||||
let req: GetProjectHealthTool = serde_json::from_value(args).map_err(|e| crate::error::AppError::BadRequest(format!("Schema validation failed. Your JSON arguments do not match the expected tool schema: {}", e)))?;
|
||||
let active_tasks = state.project.tasks.read_with(|tasks| {
|
||||
tasks
|
||||
.iter()
|
||||
@@ -1157,7 +1157,7 @@ impl McpTool for ManageCheckpointHandler {
|
||||
}
|
||||
|
||||
async fn execute(&self, args: Value, state: Arc<MemoryState>) -> crate::error::Result<String> {
|
||||
let req: ManageCheckpointTool = serde_json::from_value(args).map_err(|e| e.to_string())?;
|
||||
let req: ManageCheckpointTool = serde_json::from_value(args).map_err(|e| crate::error::AppError::BadRequest(format!("Schema validation failed. Your JSON arguments do not match the expected tool schema: {}", e)))?;
|
||||
match req {
|
||||
ManageCheckpointTool::Create { name_or_id, description, namespace } => {
|
||||
let name = name_or_id.ok_or_else(|| crate::error::AppError::Internal("name_or_id is required".to_string()))?;
|
||||
@@ -1297,7 +1297,7 @@ impl McpTool for QueryLineageHandler {
|
||||
}
|
||||
|
||||
async fn execute(&self, args: Value, state: Arc<MemoryState>) -> crate::error::Result<String> {
|
||||
let req: QueryLineageTool = serde_json::from_value(args).map_err(|e| e.to_string())?;
|
||||
let req: QueryLineageTool = serde_json::from_value(args).map_err(|e| crate::error::AppError::BadRequest(format!("Schema validation failed. Your JSON arguments do not match the expected tool schema: {}", e)))?;
|
||||
let q = req.query.to_lowercase();
|
||||
|
||||
let mut timeline = Vec::new();
|
||||
@@ -1400,7 +1400,7 @@ impl McpTool for GetNextActionableTasksHandler {
|
||||
|
||||
async fn execute(&self, args: Value, state: Arc<MemoryState>) -> crate::error::Result<String> {
|
||||
let req: GetNextActionableTasksTool =
|
||||
serde_json::from_value(args).map_err(|e| e.to_string())?;
|
||||
serde_json::from_value(args).map_err(|e| crate::error::AppError::BadRequest(format!("Schema validation failed. Your JSON arguments do not match the expected tool schema: {}", e)))?;
|
||||
let limit = req.limit.unwrap_or(5);
|
||||
|
||||
let tasks = state.project.tasks.read_with(|t| t.clone());
|
||||
@@ -1459,7 +1459,7 @@ impl McpTool for HypothesesHandler {
|
||||
}
|
||||
|
||||
async fn execute(&self, args: Value, state: Arc<MemoryState>) -> crate::error::Result<String> {
|
||||
let req: HypothesesTool = serde_json::from_value(args).map_err(|e| e.to_string())?;
|
||||
let req: HypothesesTool = serde_json::from_value(args).map_err(|e| crate::error::AppError::BadRequest(format!("Schema validation failed. Your JSON arguments do not match the expected tool schema: {}", e)))?;
|
||||
match req {
|
||||
HypothesesTool::Log { hypothesis, task_id, status, evidence } => {
|
||||
let hyp_text = hypothesis;
|
||||
@@ -1527,7 +1527,7 @@ impl McpTool for GetPreflightContextHandler {
|
||||
|
||||
async fn execute(&self, args: Value, state: Arc<MemoryState>) -> crate::error::Result<String> {
|
||||
let req: GetPreflightContextTool =
|
||||
serde_json::from_value(args).map_err(|e| e.to_string())?;
|
||||
serde_json::from_value(args).map_err(|e| crate::error::AppError::BadRequest(format!("Schema validation failed. Your JSON arguments do not match the expected tool schema: {}", e)))?;
|
||||
|
||||
let tasks = state.project.tasks.read_with(|t| t.clone());
|
||||
let tech_debts = state.code.tech_debts.read_with(|d| d.clone());
|
||||
@@ -1603,7 +1603,7 @@ impl McpTool for AgentSignalsHandler {
|
||||
}
|
||||
|
||||
async fn execute(&self, args: Value, state: Arc<MemoryState>) -> crate::error::Result<String> {
|
||||
let req: AgentSignalsTool = serde_json::from_value(args).map_err(|e| e.to_string())?;
|
||||
let req: AgentSignalsTool = serde_json::from_value(args).map_err(|e| crate::error::AppError::BadRequest(format!("Schema validation failed. Your JSON arguments do not match the expected tool schema: {}", e)))?;
|
||||
match req {
|
||||
AgentSignalsTool::Broadcast { sender, signal_type, payload, ttl_seconds } => {
|
||||
let sender = sender;
|
||||
@@ -1705,7 +1705,7 @@ impl McpTool for AutoSessionCheckpointHandler {
|
||||
|
||||
async fn execute(&self, args: Value, state: Arc<MemoryState>) -> crate::error::Result<String> {
|
||||
let req: AutoSessionCheckpointTool =
|
||||
serde_json::from_value(args).map_err(|e| e.to_string())?;
|
||||
serde_json::from_value(args).map_err(|e| crate::error::AppError::BadRequest(format!("Schema validation failed. Your JSON arguments do not match the expected tool schema: {}", e)))?;
|
||||
|
||||
let timestamp = std::time::SystemTime::now()
|
||||
.duration_since(std::time::UNIX_EPOCH)
|
||||
|
||||
Reference in new issue
Block a user