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
- Replace all ~20 remaining hardcoded
detail= strings listed above with the appropriate constant
- 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
- Either adopt
ERR_NOT_FOUND via .format() at generic 404 sites, or remove it
- Fix the comment typo on
error_constants.py:6
Notes
Context
PR #3539 (closes #3530) created
constants/error_constants.pyand 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)
api/templates.py:306,334,426"Template not found"ERR_TEMPLATE_NOT_FOUNDapi/scheduler.py:440"Template not found"ERR_TEMPLATE_NOT_FOUNDapi/scheduler.py:149"Workflow not found"ERR_WORKFLOW_NOT_FOUNDservices/workflow_automation/routes.py:127,181,344,358,487"Workflow not found"ERR_WORKFLOW_NOT_FOUNDapi/advanced_control.py:130,361"Session not found"ERR_SESSION_NOT_FOUNDapi/agent_terminal.py:495,522"Session not found"ERR_SESSION_NOT_FOUNDapi/research_browser.py:126,176,205,302,322"Session not found"ERR_SESSION_NOT_FOUNDMinor
ERR_NOT_FOUNDaterror_constants.py:6uses unnecessaryf"..."wrapper:f"{ERR_NOT_FOUND.format(resource='Workflow')}"→ should beERR_NOT_FOUND.format(resource='Workflow').Work required
detail=strings listed above with the appropriate constantERR_FAILED_TOat the top 10+ "Failed to" call sites, or remove it from the constants file and__init__.pyif not viableERR_NOT_FOUNDvia.format()at generic 404 sites, or remove iterror_constants.py:6Notes
api_endpoint_migrations_test.pyinspect.getsource()assertions must be updated for each newly migrated file (follow the pattern established in PR refactor(constants): create error_constants.py — centralize repeated error strings (#3530) #3539)ERR_JOB_NOT_FOUNDhas no remaining sites — it is correctly defined and available for future use