amir20/dozzle · error

Unable to find user

Error message

Unable to find user

What it means

The avatar handler looks up the authenticated user via auth.UserFromContext. When no user is present in the request context (which happens when authentication is misconfigured, the JWT is missing/invalid, or the auth middleware did not run), it returns 'Unable to find user' with HTTP 500.

Solutions

  1. Re-authenticate: log in again so a fresh JWT cookie is issued.
  2. Check that the request actually includes the auth cookie/token when calling the endpoint.
  3. If tokens stopped working after a restart, ensure the certificate/shared key files were not regenerated unexpectedly.
  4. Verify the avatar route is registered behind the auth middleware in routes.go.
  5. If auth is not intended, confirm the authorization provider is set to none.

Example fix

// before: calling avatar without credentials
curl http://dozzle:8080/api/profile/avatar
// after: send the session cookie
curl -b "jwt=<token>" http://dozzle:8080/api/profile/avatar
Defensive patterns

Strategy: try-catch

Validate before calling

// only call avatar endpoints when a session exists
if (!config.user) return null;

Try / catch

try {
  const res = await fetch('/api/profile/avatar');
  if (res.status === 500) return DEFAULT_AVATAR; // no user in session
  return URL.createObjectURL(await res.blob());
} catch { return DEFAULT_AVATAR; }

Prevention

When it happens

Trigger: GET /api/profile/avatar without a valid session: auth provider is enabled but the request lacks the JWT cookie, the token is expired or signed with a different shared key, or the route was accessed without going through the auth middleware.

Common situations: JWT TTL expired while the SPA still calls the avatar endpoint; server restarted with a regenerated shared_cert/shared_key invalidating old tokens; calling the endpoint directly with curl without the Authorization/cookie header; provider mismatch between frontend expectations and backend config.

Understand the failure class

Background: "User not found", "Invalid user", and "does not exist": what missing-user lookup errors mean across Rocket.Chat, LiteLLM, Phabricator, rustfs, and pnpm — this error's family across 10 libraries.

Related errors


AI-assisted analysis of amir20/dozzle@d9463cbe21 (2026-09-07). Data as JSON: /api/errors/541bbf59fe8d526d. Report an issue: GitHub.

Appendix: source

Thrown at internal/web/profile.go:30

func (h *handler) updateProfile(w http.ResponseWriter, r *http.Request) {
	username := profile.DefaultUsername
	if user := auth.UserFromContext(r.Context()); user != nil {
		username = user.Username
	}

	if err := profile.UpdateFromReader(username, r.Body); err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		log.Error().Err(err).Msg("Failed to update profile")
		return
	}

	w.WriteHeader(http.StatusOK)
}

func (h *handler) avatar(w http.ResponseWriter, r *http.Request) {
	user := auth.UserFromContext(r.Context())
	if user == nil {
		http.Error(w, "Unable to find user", http.StatusInternalServerError)
		return
	}

	url := user.AvatarURL()

	if url == "" {
		http.Error(w, "Unable to find avatar", http.StatusNotFound)
		return
	}

	log.Trace().Str("url", url).Msg("Fetching avatar")
	response, err := http.Get(url)
	if err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}

	defer response.Body.Close()

View on GitHub (pinned to d9463cbe21)