From 0f7a5bfe633f5b54dc9a25c8bfaf36449e5c2e7c Mon Sep 17 00:00:00 2001 From: mkelvers Date: Fri, 8 May 2026 16:33:31 +0200 Subject: [PATCH] fix: silence 404s when watch order not found --- integrations/jikan/relations.go | 6 ++++++ integrations/watchorder/watch_order.go | 1 + 2 files changed, 7 insertions(+) diff --git a/integrations/jikan/relations.go b/integrations/jikan/relations.go index f07832f..1945845 100644 --- a/integrations/jikan/relations.go +++ b/integrations/jikan/relations.go @@ -54,6 +54,9 @@ func (c *Client) getWatchOrder(ctx context.Context, id int) (watchorder.WatchOrd result, err := watchorder.FetchWatchOrder(requestCtx, c.httpClient, watchOrderURL) if err != nil { var statusError *watchorder.HTTPStatusError + if errors.As(err, &statusError) && statusError.StatusCode == 404 { + return watchorder.WatchOrderResult{}, watchorder.ErrWatchOrderNotFound + } if errors.Is(err, watchorder.ErrWatchOrderMarkupNotFound) { log.Printf("relations: watch-order markup missing for %d (%s): %v", id, watchOrderURL, err) } else if errors.As(err, &statusError) { @@ -95,6 +98,9 @@ func (c *Client) currentOnlyRelation(ctx context.Context, id int) ([]RelationEnt func (c *Client) GetFullRelations(ctx context.Context, id int) ([]RelationEntry, error) { result, err := c.getWatchOrder(ctx, id) if err != nil { + if errors.Is(err, watchorder.ErrWatchOrderNotFound) { + return c.currentOnlyRelation(ctx, id) + } log.Printf("relations: using current-only fallback for %d: %v", id, err) return c.currentOnlyRelation(ctx, id) } diff --git a/integrations/watchorder/watch_order.go b/integrations/watchorder/watch_order.go index 54d6e12..d088393 100644 --- a/integrations/watchorder/watch_order.go +++ b/integrations/watchorder/watch_order.go @@ -20,6 +20,7 @@ var malLinkPattern = regexp.MustCompile(`myanimelist\.net/anime/(\d+)`) var ErrInvalidWatchOrderURL = errors.New("invalid watch order url") var ErrWatchOrderMarkupNotFound = errors.New("watch order markup not found") +var ErrWatchOrderNotFound = errors.New("watch order not found") type HTTPStatusError struct { StatusCode int