File tree Expand file tree Collapse file tree 5 files changed +5
-13
lines changed
Expand file tree Collapse file tree 5 files changed +5
-13
lines changed Original file line number Diff line number Diff line change @@ -17656,7 +17656,7 @@ def test_batch_99_schedule_template_workflow_preserves_400_and_404(self):
1765617656 self.assertIn("Invalid JSON in variables parameter", source)
1765717657 # Should preserve 404 HTTPException for template not found
1765817658 self.assertIn("status_code=404", source)
17659- self.assertIn("Template not found ", source)
17659+ self.assertIn("ERR_TEMPLATE_NOT_FOUND ", source)
1766017660 # Should have 1 inner try-catch for JSON parsing
1766117661 try_count = source.count("try:")
1766217662 self.assertEqual(try_count, 1, "Should have 1 inner try-catch for JSON parsing")
Original file line number Diff line number Diff line change 1616
1717import logging
1818
19+ from constants .error_constants import ERR_TEMPLATE_NOT_FOUND
1920from fastapi import APIRouter , Depends , HTTPException
2021
2122from api .knowledge_models import (
@@ -127,7 +128,7 @@ async def get_metadata_template(template_id: str):
127128 result = await kb .get_metadata_template (template_id )
128129
129130 if result .get ("status" ) != "success" :
130- raise HTTPException (status_code = 404 , detail = "Template not found" )
131+ raise HTTPException (status_code = 404 , detail = ERR_TEMPLATE_NOT_FOUND )
131132
132133 return result
133134
Original file line number Diff line number Diff line change 1717 ERR_INVALID_CREDENTIALS ,
1818 ERR_INVALID_TOKEN ,
1919 ERR_JOB_NOT_FOUND ,
20- ERR_NOT_FOUND ,
2120 ERR_PATH_NOT_FOUND ,
2221 ERR_SESSION_NOT_FOUND ,
2322 ERR_TEMPLATE_NOT_FOUND ,
2423 ERR_WORKFLOW_NOT_FOUND ,
25- ERR_FAILED_TO ,
2624)
2725from .network_constants import ( # Legacy compatibility exports
2826 BACKEND_URL ,
140138 "CategoryDefaults" ,
141139 "ProtocolDefaults" ,
142140 # Issue #3530: Error message string constants
143- "ERR_NOT_FOUND" ,
144141 "ERR_ASSESSMENT_NOT_FOUND" ,
145142 "ERR_SESSION_NOT_FOUND" ,
146143 "ERR_FILE_NOT_FOUND" ,
153150 "ERR_WORKFLOW_NOT_FOUND" ,
154151 "ERR_INVALID_CREDENTIALS" ,
155152 "ERR_INVALID_TOKEN" ,
156- "ERR_FAILED_TO" ,
157153 # Issue #3531: API path constants
158154 "PATH_API_HEALTH" ,
159155 "PATH_HEALTH" ,
Original file line number Diff line number Diff line change 33# Author: mrveiss
44"""Shared error message string constants for HTTP responses and logging."""
55
6- # Generic resource errors (use as: ERR_NOT_FOUND.format(resource='Workflow')}")
7- ERR_NOT_FOUND = "{resource} not found"
8-
96# Specific resource errors (pre-formatted for common cases)
107ERR_ASSESSMENT_NOT_FOUND = "Assessment not found"
118ERR_SESSION_NOT_FOUND = "Session not found"
2118# Auth errors
2219ERR_INVALID_CREDENTIALS = "Invalid username or password"
2320ERR_INVALID_TOKEN = "Invalid token"
24-
25- # Operation errors — use as f-string prefix at call site
26- ERR_FAILED_TO = "Failed to {operation}"
Original file line number Diff line number Diff line change 1717from pydantic import BaseModel , Field
1818
1919from auth_middleware import check_admin_permission
20+ from constants .error_constants import ERR_SESSION_NOT_FOUND
2021from constants .ttl_constants import TTL_24_HOURS
2122
2223from .config import AutoResearchConfig
@@ -339,7 +340,7 @@ async def get_variants(
339340 key = f"autoresearch:prompt_opt:session:{ session_id } "
340341 raw = await redis .get (key )
341342 if raw is None :
342- raise HTTPException (status_code = 404 , detail = "Session not found" )
343+ raise HTTPException (status_code = 404 , detail = ERR_SESSION_NOT_FOUND )
343344 data = _json .loads (raw )
344345 return {"variants" : data .get ("all_variants" , [])}
345346
You can’t perform that action at this time.
0 commit comments