rmi-backend/app/core
opencode 92a01ffba0
Some checks failed
CI / build (push) Failing after 2s
feat(rmi-backend,audit): AppError hierarchy in app/core/errors.py (P1.10)
Phase 1 of AUDIT-2026-Q3.md item P1.10.

Codebase had 2,532 except Exception: blocks and zero AppError class.
Bare exceptions made debugging in production impossible.

This change adds a strict typed hierarchy on top of the existing
register_error_handlers() (which app/lifespan.py imports):

  AppError (base, status 500, code internal_error)
    AuthError        401  auth.unauthorized
    RateLimitError   429  ratelimit.exceeded
    ValidationError  400  validation.failed    (RMI-level, not pydantic)
    NotFoundError    404  not_found
    UpstreamError    502  upstream.failed

Each carries status_code (HTTP), code (machine-readable), and a
context dict that handlers forward to Sentry without code changes.

register_error_handlers() also now installs an AppError handler that
returns exc.to_dict() with a request_id, in addition to the existing
StarletteHTTPException / ValueError / Exception handlers.

Refs AUDIT-2026-Q3.md P1.10.
2026-07-06 17:56:36 +02:00
..
__init__.py merge: chore/cleanup-remove-bloat-and-secrets into main 2026-07-02 01:24:22 +07:00
agent_memory.py style(rmi-backend): complete lint cleanup — 1175→0 ruff errors 2026-07-06 15:43:20 +02:00
auth.py style(rmi-backend): complete lint cleanup — 1175→0 ruff errors 2026-07-06 15:43:20 +02:00
cerebras_provider.py style(rmi-backend): complete lint cleanup — 1175→0 ruff errors 2026-07-06 15:43:20 +02:00
cost_tracker.py style(rmi-backend): complete lint cleanup — 1175→0 ruff errors 2026-07-06 15:43:20 +02:00
db_pool.py style(rmi-backend): complete lint cleanup — 1175→0 ruff errors 2026-07-06 15:43:20 +02:00
duckdb_analytics.py style(rmi-backend): complete lint cleanup — 1175→0 ruff errors 2026-07-06 15:43:20 +02:00
errors.py feat(rmi-backend,audit): AppError hierarchy in app/core/errors.py (P1.10) 2026-07-06 17:56:36 +02:00
health.py merge: chore/cleanup-remove-bloat-and-secrets into main 2026-07-02 01:24:22 +07:00
health_route.py style(rmi-backend): complete lint cleanup — 1175→0 ruff errors 2026-07-06 15:43:20 +02:00
http.py merge: chore/cleanup-remove-bloat-and-secrets into main 2026-07-02 01:24:22 +07:00
lifespan.py merge: chore/cleanup-remove-bloat-and-secrets into main 2026-07-02 01:24:22 +07:00
llm_cache.py style(rmi-backend): complete lint cleanup — 1175→0 ruff errors 2026-07-06 15:43:20 +02:00
logging.py merge: chore/cleanup-remove-bloat-and-secrets into main 2026-07-02 01:24:22 +07:00
metrics.py style(rmi-backend): complete lint cleanup — 1175→0 ruff errors 2026-07-06 15:43:20 +02:00
middleware.py style(rmi-backend): complete lint cleanup — 1175→0 ruff errors 2026-07-06 15:43:20 +02:00
mistral_provider.py style(rmi-backend): complete lint cleanup — 1175→0 ruff errors 2026-07-06 15:43:20 +02:00
model_eval.py style(rmi-backend): complete lint cleanup — 1175→0 ruff errors 2026-07-06 15:43:20 +02:00
model_router.py style(rmi-backend): complete lint cleanup — 1175→0 ruff errors 2026-07-06 15:43:20 +02:00
observability.py style(rmi-backend): complete lint cleanup — 1175→0 ruff errors 2026-07-06 15:43:20 +02:00
prompt_registry.py style(rmi-backend): complete lint cleanup — 1175→0 ruff errors 2026-07-06 15:43:20 +02:00
rate_limiter.py style(rmi-backend): complete lint cleanup — 1175→0 ruff errors 2026-07-06 15:43:20 +02:00
redis.py merge: chore/cleanup-remove-bloat-and-secrets into main 2026-07-02 01:24:22 +07:00
signal_generator.py style(rmi-backend): complete lint cleanup — 1175→0 ruff errors 2026-07-06 15:43:20 +02:00
task_queue.py style(rmi-backend): complete lint cleanup — 1175→0 ruff errors 2026-07-06 15:43:20 +02:00
tracing.py style(rmi-backend): complete lint cleanup — 1175→0 ruff errors 2026-07-06 15:43:20 +02:00
tron_provider.py style(rmi-backend): complete lint cleanup — 1175→0 ruff errors 2026-07-06 15:43:20 +02:00