Skip to content

fix(http): make handler-error status visible in access log + transcription errors#9707

Merged
mudler merged 2 commits into
masterfrom
fix/access-log-status-and-transcription-error-visibility
May 7, 2026
Merged

fix(http): make handler-error status visible in access log + transcription errors#9707
mudler merged 2 commits into
masterfrom
fix/access-log-status-and-transcription-error-visibility

Conversation

@localai-bot
Copy link
Copy Markdown
Collaborator

Summary

Two small, focused fixes that together close an observability gap around transcription failures (and any handler that returns err to Echo's central error handler).

  • fix(http): log accurate status code when handler returns error — The custom xlog access-log middleware in API() reads res.Status before Echo's central HTTPErrorHandler runs, so when a handler returns an error without writing a response, the status field stays at its default 200. Every 500/503/etc. that flows through Echo's error handler was silently logged as 200. Now mirrors echo.DefaultHTTPErrorHandler's derivation: default to 500, upgrade to *echo.HTTPError.Code if applicable.
  • fix(transcription): log underlying error before returning 500 to clientTranscriptEndpoint did return err on backend failure; the actual error (gRPC error from a remote node, model load issue, ffmpeg crash, etc.) was lost. Now logs model name, staged audio path, and the underlying error before returning.

Why these together

Operators chasing transcription failures across distributed mode were getting "upstream returned 500" on the client, status=200 in the access log, and zero context anywhere in the frontend's logs. With both fixes:

  • the access-log line tells you the real status code
  • the Error line tells you what actually failed
  • Fix llama-cli: command not found #1 also benefits every other endpoint that returns errors via Echo's central handler

Test plan

  • Trigger a transcription against a model whose worker is unreachable; verify the frontend logs Transcription failed ... error=... and an access-log line with status=500.
  • Confirm successful transcriptions still log status=200 (no regression).
  • Confirm 4xx returns from middleware (e.g. bad request) log the right status code, not 500.
  • Spot-check a non-transcription endpoint that returns an error — its access line should now reflect the correct status too.

🤖 Generated with Claude Code

mudler added 2 commits May 7, 2026 13:02
The custom xlog access-log middleware in API() reads res.Status
*before* Echo's central HTTPErrorHandler runs, so when a handler
returns an error without writing a response (e.g.
TranscriptEndpoint's `return err` on backend failure) the status
field stays at its default 200. The logged line then claims
status=200 while the client receives 500 — silently hiding every
500/503/etc. that bubbles up through Echo's error handler.

Mirror echo.DefaultHTTPErrorHandler's status derivation when
err != nil and the response hasn't been committed: default to 500,
upgrade to *echo.HTTPError.Code if applicable. The logged status now
matches what the client actually sees, so failed transcription
requests stop appearing as 200 in the access log.

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
Assisted-by: Claude:claude-opus-4-7 [Claude Code]
ModelTranscriptionWithOptions surfaces real failures — gRPC errors
from a remote node, model load problems, ffmpeg conversion crashes —
but TranscriptEndpoint just did `return err`, so Echo turned it into
a 500 with a generic body and the original error was lost. Operators
chasing transcription failures across distributed mode were left
with "upstream returned 500" on the client and zero context anywhere
in the frontend's logs.

Add an xlog.Error before returning, recording model name, the staged
audio path, and the underlying error. Combined with the access-log
status fix, a failing transcription now leaves an audit trail (real
status code in the access line, real cause in an Error line) instead
of vanishing.

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
Assisted-by: Claude:claude-opus-4-7 [Claude Code]
@mudler mudler merged commit cec5c4f into master May 7, 2026
50 of 51 checks passed
@mudler mudler deleted the fix/access-log-status-and-transcription-error-visibility branch May 7, 2026 15:27
@localai-bot localai-bot added the bug Something isn't working label May 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ready-to-merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

llama-cli: command not found

2 participants