Repository navigation
Description
What happened
The "your taste profile" screen is broken for everyone, on a default install.
On the Android app, whenever a user opens the screen that shows their taste profile
(top genres, favourite directors), the server fails the request and returns an error.
It does not fail sometimes or under load — it fails every single time. There is no
partial result and no fallback; the screen has never worked on this deployment.
Over a 17.5-hour window on our production server this happened 66 times, to 9 different
people. Every one of those 66 requests failed. The people affected did nothing unusual —
they just opened the app.
The reason it affects everyone is the part worth flagging: the recommendations feature is
switched off by default. When it is off, the server is supposed to simply not offer
these screens. Instead it still advertises them, and then falls over when anyone opens
one. So this is not an exotic misconfiguration — a brand-new Silo install, straight out of
the box, has a broken taste-profile screen.
The failure is contained: the server catches it, so nothing crashes or restarts, and other
playback and browsing continues normally. But nothing in the logs says "recommendations are
disabled" — it just looks like an internal server error, which is why this sat unnoticed.
A second screen ("because you watched…") is broken in exactly the same way. Nobody has hit
it yet on this server, so it has caused no visible damage, but it will fail the moment
someone does.
Where it shows up: Android app (all 66 observed cases), taste-profile screen. Not
client-specific in principle — any client calling this endpoint gets the same error.
Steps to reproduce
Commands assume the repository root is the cwd.
- Run a Silo server against a database with recommendations left at their default setting
(i.e. do not setrecommendations.enabled— absent means off). - Sign in as any user with a profile.
GET /api/v1/recommendations/taste-profile.- Observe HTTP 500, and a recovered nil-pointer panic in the server log.
Reproduced directly against the handler, which panics deterministically:
$ go test ./internal/api/handlers/ -run TestRepro -v
=== RUN TestReproTasteProfileNilEngine
--- FAIL: TestReproTasteProfileNilEngine (0.00s)
panic: runtime error: invalid memory address or nil pointer dereference [recovered, repanicked]
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x1bfab6d]
...
github.com/Silo-Server/silo-server/internal/api/handlers.(*RecommendationsHandler).HandleTasteProfile(...)
/opt/silo-server/internal/api/handlers/recommendations.go:248 +0x10d
FAIL github.com/Silo-Server/silo-server/internal/api/handlers 0.166s
The same test shape against HandleBecauseWatched (with item_id set via a chi route
context, so it gets past the empty-ID guard) panics at recommendations.go:197.
Expected behavior
With recommendations disabled, GET /api/v1/recommendations/taste-profile should return the
same empty TasteProfileSummary the handler already falls back to on an engine error —
{"top_genres":[],"favorite_directors":[],"signal_counts":{}} with HTTP 200 — or the
routes should not be registered at all. It should never return 500, and never panic.
Silo version / commit
3ddc9d66 (deployed as silo:local). The defect is not introduced by that commit —
internal/api/handlers/recommendations.go is byte-identical on origin/main, and the code
has been unchanged since c085b12f ("Initial Silo migration", 2026-05-22).
Deployment
Docker.
Clients affected
- Android (all 66 observed occurrences,
user_agent=ktor-client) - Not client-specific in principle — any client calling the endpoint gets HTTP 500
Relevant logs
Raw copy-paste from docker logs silo, with viewer IPs redacted to x.x.x.x; nothing else altered.
time=2026-08-18T03:00:56.859Z level=INFO msg="api request" component=api component=api request_id=4580b34475a1/0JCmU13lz8-352411 method=GET path=/api/v1/recommendations/taste-profile path_pattern=/api/v1/recommendations/taste-profile status=500 duration_ms=14 client_ip=x.x.x.x user_agent=ktor-client node_id=4580b34475a1 user_id=1863 session_id=9644ebf5-3408-44e8-ad2d-5dbdfb368698
panic: runtime error: invalid memory address or nil pointer dereference
-> github.com/Silo-Server/silo-server/internal/api/handlers.(*RecommendationsHandler).HandleTasteProfile
-> /app/internal/api/handlers/recommendations.go:248
net/http.HandlerFunc.ServeHTTP
/usr/local/go/src/net/http/server.go:2284
github.com/go-chi/chi/v5.(*Mux).routeHTTP
/go/pkg/mod/github.com/go-chi/chi/[email protected]/mux.go:479
net/http.HandlerFunc.ServeHTTP
/usr/local/go/src/net/http/server.go:2284
github.com/Silo-Server/silo-server/internal/api/middleware.RequireProfile.func1
/app/internal/api/middleware/profile.go:29
net/http.HandlerFunc.ServeHTTP
/usr/local/go/src/net/http/server.go:2284
github.com/go-chi/chi/v5.(*Mux).ServeHTTP
/go/pkg/mod/github.com/go-chi/chi/[email protected]/mux.go:73
github.com/go-chi/chi/v5.(*Mux).Mount.func1
/go/pkg/mod/github.com/go-chi/chi/[email protected]/mux.go:321Observed rate over the sample window:
$ docker logs silo 2>&1 | grep -c 'panic: runtime error'
66
$ docker logs silo 2>&1 | grep -A4 'panic: runtime error' | grep -oE 'recommendations\.go:[0-9]+' | sort | uniq -c
66 recommendations.go:248
$ docker logs silo 2>&1 | grep 'recommendations/taste-profile' | grep -oE 'status=[0-9]+' | sort | uniq -c
66 status=500
$ docker logs silo 2>&1 | grep 'recommendations/taste-profile' | grep -oE 'user_id=[0-9]+' | sort -u | wc -l
9Window: 2026-08-17T13:35:31.713Z → 2026-08-18T03:00:56.859Z. 66 requests, 66 failures,
9 distinct users, 0 successes.
Technical detail
Root cause
internal/api/handlers/recommendations.go:248 calls a method on h.engine
(recommendationsEngine, an interface) without a nil check:
summary, err := h.engine.GetTasteProfileSummary(r.Context(), userID, profileID)h.engine is nil, so this is a nil-interface method call → SIGSEGV, recovered by chi's
middleware.Recoverer (internal/api/router.go:3294) and returned as HTTP 500.
The chain that leaves it nil on a default install:
internal/config/db_loader.go:409—recommendations.enableddefaults tofalse
(boolOr(m, "recommendations.enabled", false)). Confirmed absent fromserver_settings
on the affected deployment, so the default applies.cmd/silo/main.go:1894—deps.Recommenderanddeps.RatingsRepoare only assigned
insideif cfg.Recommendations.Enabled && deps.DB != nil. Both stay nil.internal/api/router.go:534-539— the router does not inherit that decision. With
deps.RatingsRepo == nilbutdeps.DB != nilit constructs its own ratings repo:} else if deps.DB != nil { ratingsRepo = catalog.NewRatingsRepo(deps.DB) }
internal/api/router.go:1591-1598— the handler is then built becauseratingsRepo != nil,
with a nil engine andenabled: deps.Recommender != nil(i.e.false):recsHandler = handlers.NewRecommendationsHandler(deps.Recommender, recsReader, deps.UserStoreProvider, ratingsRepo, recsRepo, deps.Recommender != nil)
internal/api/router.go:2741-2751— routes are registered onrecsHandler != nil, which
has nothing to do with whether the engine exists./taste-profilegoes live pointing at a
handler that cannot serve it.
So the enabled flag is threaded through correctly and simply never consulted by this handler.
Why only these two handlers
Every other handler in the file guards on entry; the two that touch h.engine do not:
| Handler | Line | Guard | Touches |
|---|---|---|---|
HandleSimilar |
92 | if !h.enabled (93) |
h.engine (112) |
HandleForYouMain |
126 | if h.reader == nil (127) |
reader |
HandleForYouRows |
152 | if h.reader == nil (153) |
reader |
HandleBecauseWatched |
182 | none | h.engine (197) |
HandleSimilarUsers |
215 | if h.reader == nil (216) |
reader |
HandleTasteProfile |
244 | none | h.engine (248) |
HandleDiscover |
448 | h.reader == nil || h.Fetcher == nil (449) |
fetcher |
HandleSection |
532 | h.reader == nil || h.Fetcher == nil (533) |
fetcher |
HandleSimilar is the precedent: it also calls h.engine, and it guards with !h.enabled.
HandleBecauseWatched is latent only because the endpoint is unused — zero
/api/v1/recommendations/because-watched requests in the whole 17.5h log window. It is the
same defect and should be fixed in the same change, not deferred until it shows up in
production.
Suggested fix
Add the entry guard the siblings already use, to both handlers, returning the empty
summary the handler is already written to fall back to:
func (h *RecommendationsHandler) HandleTasteProfile(w http.ResponseWriter, r *http.Request) {
if !h.enabled || h.engine == nil {
writeJSON(w, http.StatusOK, recommendations.TasteProfileSummary{
TopGenres: []string{},
FavoriteDirectors: []string{},
SignalCounts: map[string]int{},
})
return
}
...This keeps the v1 contract additive-safe: the response shape is unchanged, and the status
code moves 500 → 200 on a path that is currently always an error, so no working client
behaviour is being repurposed.
Worth considering separately (not required to fix the panic): the router builds a
recommendations handler and registers its routes even when the feature is disabled. Gating
registration on the engine's existence would remove this whole class of bug rather than
patching it handler by handler — but it would make the endpoints 404 instead of 200 when
disabled, which is a client-visible contract decision, so I have not assumed it here.
Discovery context
Found incidentally while auditing production logs during an unrelated stream-telemetry
soak — not by a user report. Nobody had reported the broken screen, which is consistent
with it having never worked.
AI Disclosure
- Tool(s): Claude Code
- Model(s): claude-opus-5
- Involvement: AI-generated, human verified the repro
- Adversarial review: my first pass claimed
HandleBecauseWatchedpanicked identically, but
the initial repro returned HTTP 400 —chi.URLParamyields""outside a route context,
so it exits at the "Item ID is required" check before reachingh.engine. Re-ran with a
populatedchi.RouteContext, which panics atrecommendations.go:197as claimed; the
table above reflects the corrected finding. I also initially described the engine as "nil
in this deployment" and traced it further to confirm the stronger and more actionable
claim: it is nil on any install that has not explicitly enabled recommendations, i.e. the
default. Verifiedrecommendations.gois byte-identical onorigin/mainbefore
attributing the defect toc085b12frather than the locally deployed commit.
Activity
Tobechukwu-Njoku commentedon Aug 23, 2026
The 500 and the nil-pointer panic look fixed on
main— #679 ("fix(recommendations): do not panic when the engine is disabled") merged 2026-08-21, after this was filed.Checked against
mainat91c3d7bd:internal/api/handlers/recommendations.go:92—engineUnavailable()returns!h.enabled || h.engine == nil.h.engine.SimilarItems(:124),h.engine.BecauseYouWatched(:214),h.engine.GetTasteProfileSummary(:270) — and each is directly preceded by anengineUnavailable()guard at :105, :195 and :262. I went through every method onRecommendationsHandlerlooking for an unguarded path and there isn't one; nothing else in the file touchesh.engineat all.internal/api/handlers/recommendations_engine_guard_test.gocovers all three, and the tests pass:That covers the reproduction in this issue (step 4: HTTP 500 plus a recovered nil-pointer panic) and the "because you watched" screen flagged as broken the same way — both now return an empty 200 rather than failing.
One part of the report that #679 does not address, so worth a maintainer's call before closing: the observation that the server still advertises these screens while recommendations are disabled. #679 makes the endpoints answer with empty results; it doesn't stop them being offered. If the intent was for the screens not to appear at all on a default install, that's still open and probably wants its own issue.
Quick104 commentedon Sep 4, 2026
Fixed on main by #679.
The taste-profile, Because You Watched, and Similar handlers now guard against a disabled or absent recommendations engine and return empty HTTP 200 results instead of panicking.
All three nil-engine regression tests pass on current main. This satisfies the empty-response behavior requested here; hiding disabled recommendation screens is a separate UI decision.
Closing as completed after checking current main (
a4c8f4b2).