Skip to content

Replace broad except Exception with specific error handling #11

@jtdub

Description

@jtdub

Problem

Every router endpoint catches Exception and returns HTTP 400:

except Exception as e:
    raise HTTPException(status_code=400, detail=f"Failed to ...: {str(e)}") from e

This masks actual server errors (e.g., KeyError, TypeError, AttributeError) as "bad request" responses when they should be 500 Internal Server Error. It also swallows tracebacks, making debugging difficult.

Suggested Fix

  • Catch specific expected exceptions (e.g., ValueError, KeyError for invalid platform) and return 400.
  • Let unexpected exceptions propagate to FastAPI's default 500 handler (or use a custom exception handler).
  • Consider structured error responses with error codes for better client-side handling.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions