summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-05-07 15:56:35 +0300
committerPaul Buetow <paul@buetow.org>2026-05-07 15:56:35 +0300
commit7f3ca21cc42979b8f1898f5dfd81f51f04aed5e0 (patch)
tree47987d9c73f2ce760cefed045ec85eee53747ff7 /internal
parent3f70adb2c24d558be645aacb11a97d5f95f69b76 (diff)
Fix podcast browser workflows for k1
Diffstat (limited to 'internal')
-rw-r--r--internal/api/handlers_podcast.go4
-rw-r--r--internal/api/handlers_podcast_test.go4
-rw-r--r--internal/service/podcast.go2
-rw-r--r--internal/service/service.go1
4 files changed, 8 insertions, 3 deletions
diff --git a/internal/api/handlers_podcast.go b/internal/api/handlers_podcast.go
index 4568022..f93b15c 100644
--- a/internal/api/handlers_podcast.go
+++ b/internal/api/handlers_podcast.go
@@ -58,6 +58,10 @@ func (s *Server) handleSubscribePodcast(w http.ResponseWriter, r *http.Request)
forbidden(w, "access denied")
return
}
+ if errors.Is(err, service.ErrInvalidFeed) {
+ badRequest(w, "invalid feed")
+ return
+ }
s.logger.Error("subscribe podcast", "err", err)
writeJSON(w, http.StatusInternalServerError, map[string]string{"error": "failed to subscribe"})
return
diff --git a/internal/api/handlers_podcast_test.go b/internal/api/handlers_podcast_test.go
index 33a129c..963c2a0 100644
--- a/internal/api/handlers_podcast_test.go
+++ b/internal/api/handlers_podcast_test.go
@@ -303,8 +303,8 @@ func TestPodcastE2E_FullFlow(t *testing.T) {
rr := httptest.NewRecorder()
srv.ServeHTTP(rr, req)
- if rr.Code != http.StatusInternalServerError && rr.Code != http.StatusBadRequest {
- t.Fatalf("expected 400 or 500, got %d", rr.Code)
+ if rr.Code != http.StatusBadRequest {
+ t.Fatalf("expected %d, got %d", http.StatusBadRequest, rr.Code)
}
})
diff --git a/internal/service/podcast.go b/internal/service/podcast.go
index 77c6118..4425bfc 100644
--- a/internal/service/podcast.go
+++ b/internal/service/podcast.go
@@ -129,7 +129,7 @@ func (s *podcastService) SubscribeFeed(ctx context.Context, feedURL, setName str
parsed, err := s.parseFeed(feedURL)
if err != nil {
- return nil, fmt.Errorf("parse feed: %w", err)
+ return nil, fmt.Errorf("%w: %v", ErrInvalidFeed, err)
}
safeName, setPath := s.resolveSetPath(setName, parsed.Title)
diff --git a/internal/service/service.go b/internal/service/service.go
index f61655c..de218dc 100644
--- a/internal/service/service.go
+++ b/internal/service/service.go
@@ -20,6 +20,7 @@ var (
ErrUnsupportedExtension = errors.New("unsupported file extension")
ErrAlreadyBootstrapped = errors.New("already bootstrapped")
ErrInvalidCredentials = errors.New("invalid credentials")
+ ErrInvalidFeed = errors.New("invalid feed")
)
// MediaQueryFilter defines query parameters for listing media from the API layer.