diff --git a/appview/state/state.go b/appview/state/state.go index d7e8e1a9..67a3b222 100644 --- a/appview/state/state.go +++ b/appview/state/state.go @@ -160,19 +160,24 @@ func (s *State) Keys(w http.ResponseWriter, r *http.Request) { user = strings.TrimPrefix(user, "@") if user == "" { - w.Write([]byte("not found")) + w.WriteHeader(http.StatusBadRequest) return } id, err := auth.ResolveIdent(r.Context(), user) if err != nil { - w.Write([]byte("not found")) + w.WriteHeader(http.StatusInternalServerError) return } pubKeys, err := s.db.GetPublicKeys(id.DID.String()) if err != nil { - w.Write([]byte("not found")) + w.WriteHeader(http.StatusNotFound) + return + } + + if len(pubKeys) == 0 { + w.WriteHeader(http.StatusNotFound) return } diff --git a/knotserver/jetstream.go b/knotserver/jetstream.go index d8a80297..4cd2f5ca 100644 --- a/knotserver/jetstream.go +++ b/knotserver/jetstream.go @@ -177,6 +177,11 @@ func (h *Handle) fetchAndAddKeys(ctx context.Context, did string) error { } defer resp.Body.Close() + if resp.StatusCode == http.StatusNotFound { + l.Info("no keys found for did", "did", did) + return nil + } + if ct := resp.Header.Get("Content-Type"); !strings.HasPrefix(ct, "text/plain") { return fmt.Errorf("unexpected content type: %s", ct) }