Skip to content

fix(workflows): four routes convert their own HTTPException into a 500, so a deliberate 404 reads as a server error #17653

Open

Description

@mrveiss

Four routes convert their own HTTPException into a 500

Found while fixing #17014, which needed the guard on the routes it gave a 403. These four
are pre-existing and got no ownership check, so they were left out of that PR.

The shape, in autobot-backend/services/workflow_automation/routes.py:

    try:
        ...
        raise HTTPException(status_code=404, detail=ERR_WORKFLOW_NOT_FOUND)
    except Exception as e:
        logger.error(...)
        raise HTTPException(status_code=500, detail="Internal server error")

HTTPException is an Exception, so the route's own deliberate status is caught one line
later and replaced. A 404 the code raises on purpose reaches the client as "Internal server
error."

route line
create_workflow :52
get_active_workflows :211
get_completed_workflows :235
create_workflow_from_chat :257

Enumerated with an AST walk over the file, not grep: the condition is a Try whose handlers
include Exception but not HTTPException, and whose body raises HTTPException
.

Five routes in the same file already carry except HTTPException: raise, and #17014 added it
to the six it gave ownership checks. So the file already contains both the defect and its
remedy, which is what makes this a class rather than four bugs.

Why it matters beyond tidiness

Lineage

#10662 — "/agents/recommend swallows HTTPException(400) into a generic 500" — fixed this
exact defect at one route and closed. The class was never swept, so it is still here in
another file. Fixing the class once is the point of this issue.

Acceptance criteria

  • Each of the four routes above re-raises HTTPException before its broad handler, so the
    status the code chose is the status the client receives.
  • A guard fails when a route in this file has a try that raises HTTPException and
    catches Exception without re-raising it first. The AST condition above is the check;
    grep cannot express it.
  • The guard covers the whole autobot-backend/ route surface, not just this file —
    fix(api): /agents/recommend swallows HTTPException(400) into a generic 500 #10662 shows a one-file fix does not hold.
  • A test asserts a deliberate 404 from one of these routes arrives as 404.

Related

#17014 (found here), #10662 (same defect, fixed once at another route)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendbugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions