From 13e97b48d4de2ed7007a9530ed3a4b42b631ce35 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Tue, 19 May 2026 00:25:06 +0300 Subject: Map service errors to correct HTTP status codes (was 500) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Three more handlers had the same pattern as the RevokeShare bug fixed in 0848488: the service returned a plain errors.New(...) for an expected condition, so handleError fell through to its default 500 branch instead of mapping to 404/400. - browse.GetThumbnail → ErrNotFound (404 instead of 500) when the media row has no thumbnail path. - tag.RemoveTag → ErrNotFound (404 instead of 500) when the tag name does not exist. DELETE /media/{id}/tags/{unknown} now returns 404. - write.RegenerateSetCover → new sentinel ErrEmptySetForCover, mapped to 400 in handleError, when the target set contains no media files eligible to be promoted to a cover. S15 (auth-boundary negatives) is tightened: the share-revoke step used to accept {404, 500} as a workaround for the bug; it now requires 404. A new section C2 locks in the three regressions above so they cannot silently return 500 again. Verified end-to-end via curl: DELETE /media/{id}/tags/unknown → 404, DELETE /shares/unknown-token → 404. Full LLM e2e suite 15/15 still passes against the rebuilt server. Co-Authored-By: Claude Opus 4.7 --- player-server/internal/service/write.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'player-server/internal/service/write.go') diff --git a/player-server/internal/service/write.go b/player-server/internal/service/write.go index f2f5080..23fd130 100644 --- a/player-server/internal/service/write.go +++ b/player-server/internal/service/write.go @@ -211,7 +211,10 @@ func (s *writeService) RegenerateSetCover(ctx context.Context, setID int64, fold return fmt.Errorf("copy thumbnail cover: %w", err) } default: - return errors.New("no media files available for cover") + // Use the sentinel so handleError maps this to HTTP 400 (bad request) + // instead of falling through to the default 500 branch — the request + // is well-formed, the set just has nothing usable as a cover. + return ErrEmptySetForCover } return nil -- cgit v1.2.3