Skip to content

Fix: Sanitize the pagination parameters#136

Merged
dstpierre merged 2 commits intostaticbackendhq:mainfrom
gabrnavarro:bot/task-37-issue-135
Mar 11, 2026
Merged

Fix: Sanitize the pagination parameters#136
dstpierre merged 2 commits intostaticbackendhq:mainfrom
gabrnavarro:bot/task-37-issue-135

Conversation

@gabrnavarro
Copy link
Copy Markdown
Contributor

What changed

Sanitized the pagination parameters in getPagination() (db.go) to clamp page and size to a minimum value of 1 when 0 or negative values are provided.

Why

When 0 is sent as the page number (e.g., from the Go client library which sends 0 as the default int value), an EOF error is returned. Similarly, a size of 0 or negative values could cause unexpected behavior.

Fixes #135

Testing

Added TestGetPaginationSanitizesValues in db_test.go with table-driven subtests covering:

  • Default values when no params are provided
  • Valid values pass through unchanged
  • Zero page/size get clamped to 1
  • Negative page/size get clamped to 1
  • Both zero simultaneously

All existing tests continue to pass.

@dstpierre dstpierre merged commit 0b595ab into staticbackendhq:main Mar 11, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sanitize the pagination parameters

2 participants