Skip to content

tech-debt(constants): complete error_constants adoption — unused ERR_FAILED_TO/ERR_NOT_FOUND and ~20 remaining hardcoded sites #3550

@mrveiss

Description

@mrveiss

Context

PR #3539 (closes #3530) created constants/error_constants.py and wired it into 6 files. A post-merge code review identified incomplete adoption.

Issues

Dead constants — never adopted

  • ERR_FAILED_TO = "Failed to {operation}" — defined and exported but zero call sites updated. The 40+ "Failed to" sites that motivated this constant were not replaced.
  • ERR_NOT_FOUND = "{resource} not found" — same: defined but never used with .format() at call sites.

Remaining hardcoded sites (~20)

File Detail string Constant to use
api/templates.py:306,334,426 "Template not found" ERR_TEMPLATE_NOT_FOUND
api/scheduler.py:440 "Template not found" ERR_TEMPLATE_NOT_FOUND
api/scheduler.py:149 "Workflow not found" ERR_WORKFLOW_NOT_FOUND
services/workflow_automation/routes.py:127,181,344,358,487 "Workflow not found" ERR_WORKFLOW_NOT_FOUND
api/advanced_control.py:130,361 "Session not found" ERR_SESSION_NOT_FOUND
api/agent_terminal.py:495,522 "Session not found" ERR_SESSION_NOT_FOUND
api/research_browser.py:126,176,205,302,322 "Session not found" ERR_SESSION_NOT_FOUND

Minor

  • Comment on ERR_NOT_FOUND at error_constants.py:6 uses unnecessary f"..." wrapper: f"{ERR_NOT_FOUND.format(resource='Workflow')}" → should be ERR_NOT_FOUND.format(resource='Workflow').

Work required

  1. Replace all ~20 remaining hardcoded detail= strings listed above with the appropriate constant
  2. Either adopt ERR_FAILED_TO at the top 10+ "Failed to" call sites, or remove it from the constants file and __init__.py if not viable
  3. Either adopt ERR_NOT_FOUND via .format() at generic 404 sites, or remove it
  4. Fix the comment typo on error_constants.py:6

Notes

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions