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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user