fix(api): remove duplicate /api/traces endpoint that broke React UI#9427
Merged
mudler merged 2 commits intomudler:masterfrom Apr 20, 2026
Merged
Conversation
621ac83 to
65309c9
Compare
The API Traces tab in /app/traces always showed (0) traces despite requests
being recorded.
The /api/traces endpoint was registered in both localai.go and ui_api.go.
The ui_api.go version wrapped the response as {"traces": [...]} instead of
the flat []APIExchange array that both the React UI (Traces.jsx) and the
legacy Alpine.js UI (traces.html) expect. Because Echo matched the ui_api.go
handler, Array.isArray(apiData) always returned false, making the API Traces
tab permanently empty.
Remove the duplicate endpoints from ui_api.go so only the correct flat-array
version in localai.go is served.
Also use mime.ParseMediaType for the Content-Type check in the trace
middleware so requests with parameters (e.g. application/json; charset=utf-8)
are still traced.
Signed-off-by: Pawel Brzozowski <paul@ontux.net>
65309c9 to
f55a4b2
Compare
richiejp
approved these changes
Apr 20, 2026
Collaborator
richiejp
left a comment
There was a problem hiding this comment.
Oddly enough, this did work despite the problem always being there and probably it stopped working after a refactor.
The solution looks about right, thanks!
Contributor
Author
Thanks for the approval! I think I stopped pending checks by merging the master into this branch. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The API Traces tab in
/app/tracesalways showed (0) traces — no API request/response pairs were ever displayed, even though Backend Traces worked fine.Root Cause
The
/api/tracesendpoint was registered in two places:core/http/routes/localai.go— returns a flat[]APIExchangearray ✅core/http/routes/ui_api.go— returns a wrapped{"traces": [...]}object ❌Echo matched the
ui_api.gohandler. The React UI (Traces.jsx) doesArray.isArray(apiData) ? apiData : [], which always evaluated to[]because the response was an object, not an array. The legacy Alpine.js UI (traces.html) also assigns the response directly and expected an array.Both bugs were introduced in commit 99b5c5f ("feat(api): Allow tracing of requests and responses #7609").
Fix
/api/tracesand/api/traces/clearendpoints fromui_api.go, keeping only the correct flat-array versions inlocalai.gomime.ParseMediaType()for the Content-Type check in the trace middleware, so requests with parameters (e.g.application/json; charset=utf-8) are still tracedTesting
Built and deployed to a test instance. Verified:
GET /api/tracesreturns a flat JSON array