Commit Graph

3 Commits

Author SHA1 Message Date
Bingxi Zhao (Frank)
42941faaff fix prs 2026-06-21 14:43:41 +08:00
Bingxi Zhao (Frank)
1d9a4a904d fix(logging): silence routine 200 access-log spam on all launch paths
The backend was logging every request (the chatty frontend polling of
/settings, /tools, /knowledge/list, /settings/llm-options, ...) as
`::1:0 - "GET ... 200 OK"`. uvicorn's per-request access log was only disabled
in run_server.py (access_log=False); the `deeptutor start` launcher and the
Docker entrypoints invoked uvicorn directly with it still on, so the 200s
leaked.

- launcher.py + Dockerfile (production start-backend.sh and the dev supervisord
  program): add `--no-access-log` so all launch paths match run_server.py.
- Funnel access logging through the existing selective_access_log middleware
  (non-200 only), but log via a `deeptutor.access` logger with its own INFO
  stdout handler (propagate=False). Previously it used `uvicorn.access`, which
  has no handler once uvicorn's access log is off, and the root console handler
  runs at WARNING — so non-200s were being silently dropped. Now 200s are quiet
  and 4xx/5xx still surface.
- Rewrite the middleware test to capture on the deeptutor.access logger directly
  (it no longer propagates to root).

Verified: live server with --no-access-log logs nothing for 200s and prints
`127.0.0.1 - "GET /api/v1/... HTTP/1.1" 404` for a 404. ruff + pytest (2447) green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-20 22:01:01 +08:00
kagura-agent
1c6890290a fix(api): add missing http_version arg in selective_access_log middleware
The selective_access_log middleware uses logging.getLogger('uvicorn.access'),
which inherits uvicorn's AccessFormatter. That formatter unpacks record.args
into five values (client_addr, method, full_path, http_version, status_code),
but the middleware only passed four — omitting http_version — causing a
ValueError ('not enough values to unpack') on every non-200 response.

Add the missing http_version argument from the ASGI scope, defaulting to
'1.1' when absent.

Fixes #334

Signed-off-by: kagura-agent <kagura.chen28@gmail.com>
2026-04-17 08:18:49 +08:00