fix(api): clamp negative offset instead of erroring + clarify duration_sec=0

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-04-21 19:27:21 -04:00
parent db2ee3b21f
commit b94b7514f9
4 changed files with 81 additions and 3 deletions
+3 -3
View File
@@ -124,8 +124,8 @@ func trackRefFrom(t dbq.Track, albumTitle, artistName string) TrackRef {
}
// parsePaging reads limit/offset from the query string, applying defaults
// and clamping. Returns a 400-worthy error when the values are non-numeric
// or negative; out-of-range values silently clamp (deliberate — UX).
// and clamping. Returns a 400-worthy error when the values are non-numeric;
// out-of-range values silently clamp (deliberate — UX).
func parsePaging(raw url.Values) (limit, offset int, err error) {
const (
defLimit = 50
@@ -151,7 +151,7 @@ func parsePaging(raw url.Values) (limit, offset int, err error) {
return 0, 0, errBadPaging
}
if n < 0 {
return 0, 0, errBadPaging
n = 0
}
offset = n
}