Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion autobot-backend/api/api_endpoint_migrations_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17656,7 +17656,7 @@ def test_batch_99_schedule_template_workflow_preserves_400_and_404(self):
self.assertIn("Invalid JSON in variables parameter", source)
# Should preserve 404 HTTPException for template not found
self.assertIn("status_code=404", source)
self.assertIn("Template not found", source)
self.assertIn("ERR_TEMPLATE_NOT_FOUND", source)
# Should have 1 inner try-catch for JSON parsing
try_count = source.count("try:")
self.assertEqual(try_count, 1, "Should have 1 inner try-catch for JSON parsing")
Expand Down
3 changes: 2 additions & 1 deletion autobot-backend/api/knowledge_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import logging

from constants.error_constants import ERR_TEMPLATE_NOT_FOUND
from fastapi import APIRouter, Depends, HTTPException

from api.knowledge_models import (
Expand Down Expand Up @@ -127,7 +128,7 @@ async def get_metadata_template(template_id: str):
result = await kb.get_metadata_template(template_id)

if result.get("status") != "success":
raise HTTPException(status_code=404, detail="Template not found")
raise HTTPException(status_code=404, detail=ERR_TEMPLATE_NOT_FOUND)

return result

Expand Down
4 changes: 0 additions & 4 deletions autobot-backend/constants/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@
ERR_INVALID_CREDENTIALS,
ERR_INVALID_TOKEN,
ERR_JOB_NOT_FOUND,
ERR_NOT_FOUND,
ERR_PATH_NOT_FOUND,
ERR_SESSION_NOT_FOUND,
ERR_TEMPLATE_NOT_FOUND,
ERR_WORKFLOW_NOT_FOUND,
ERR_FAILED_TO,
)
from .network_constants import ( # Legacy compatibility exports
BACKEND_URL,
Expand Down Expand Up @@ -140,7 +138,6 @@
"CategoryDefaults",
"ProtocolDefaults",
# Issue #3530: Error message string constants
"ERR_NOT_FOUND",
"ERR_ASSESSMENT_NOT_FOUND",
"ERR_SESSION_NOT_FOUND",
"ERR_FILE_NOT_FOUND",
Expand All @@ -153,7 +150,6 @@
"ERR_WORKFLOW_NOT_FOUND",
"ERR_INVALID_CREDENTIALS",
"ERR_INVALID_TOKEN",
"ERR_FAILED_TO",
# Issue #3531: API path constants
"PATH_API_HEALTH",
"PATH_HEALTH",
Expand Down
6 changes: 0 additions & 6 deletions autobot-backend/constants/error_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
# Author: mrveiss
"""Shared error message string constants for HTTP responses and logging."""

# Generic resource errors (use as: ERR_NOT_FOUND.format(resource='Workflow')}")
ERR_NOT_FOUND = "{resource} not found"

# Specific resource errors (pre-formatted for common cases)
ERR_ASSESSMENT_NOT_FOUND = "Assessment not found"
ERR_SESSION_NOT_FOUND = "Session not found"
Expand All @@ -21,6 +18,3 @@
# Auth errors
ERR_INVALID_CREDENTIALS = "Invalid username or password"
ERR_INVALID_TOKEN = "Invalid token"

# Operation errors — use as f-string prefix at call site
ERR_FAILED_TO = "Failed to {operation}"
3 changes: 2 additions & 1 deletion autobot-backend/services/autoresearch/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from pydantic import BaseModel, Field

from auth_middleware import check_admin_permission
from constants.error_constants import ERR_SESSION_NOT_FOUND
from constants.ttl_constants import TTL_24_HOURS

from .config import AutoResearchConfig
Expand Down Expand Up @@ -339,7 +340,7 @@ async def get_variants(
key = f"autoresearch:prompt_opt:session:{session_id}"
raw = await redis.get(key)
if raw is None:
raise HTTPException(status_code=404, detail="Session not found")
raise HTTPException(status_code=404, detail=ERR_SESSION_NOT_FOUND)
data = _json.loads(raw)
return {"variants": data.get("all_variants", [])}

Expand Down
Loading