Skip to content

fix(audiobooks): return all authors/series for non-paginated ABS requests - #317

Merged
Quick104 merged 5 commits into
mainfrom
fix/abs-authors-return-all
Jul 6, 2026
Merged

Quick104 merged 5 commits into
mainfrom
fix/abs-authors-return-all

Conversation

@Quick104

@Quick104 Quick104 commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

Problem

The ABS Authors page in client apps only shows the first ~50 authors and won't scroll further. Clients fetch GET /api/libraries/{id}/authors with no limit/page (real ABS returns the complete list for that form and clients scroll it locally), but Silo applied a default limit of 50 (25 for /series) to the non-paginated form — a bare {authors:[...]} truncated to the first page, with no total field to signal more exist.

Fix

Non-paginated /authors and /series requests now use limit=0 ("return all" — the contract the store layer already implements). Explicitly paginated requests are unchanged, as are the capped filter-data/search author buckets.

Response-size note: this returns the full author set (~100k objects on a large library) exactly as real ABS does; the MV-backed query serves it in one indexed read.

Verification

  • go build / go test ./internal/audiobooks/... pass.
  • Reproduced on a dev deployment via debug request logging: the reporting client sends the non-paginated form; details in internal notes.

Disclosure

Implemented with Claude Code (AI-assisted).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved non-paginated library author and series endpoints to avoid unintended default limits, while enforcing maximum caps for very large result sets.
    • Added warnings for non-paginated requests when results are truncated.
    • Fixed author image handling by using the correct photo field for poster display.
  • Security / Logging
    • Updated access logging to redact credential-related query parameters and to record sanitized query details and User-Agent when available.

Quick104 and others added 2 commits July 6, 2026 08:21
GetAuthorByID selected poster_path from the people table, but the
person-image column is photo_path, so every GET /api/authors/{id}
request failed with SQLSTATE 42703 and a 500. Since photo_path is
NOT NULL DEFAULT '', the nullable scan is also dropped.

Co-Authored-By: Claude Fable 5 <[email protected]>
…ests

Real ABS returns the FULL author list when the client sends no
limit/page — the official app and other clients fetch it once and
scroll locally. Silo applied a default limit (50 authors, 25 series)
to the non-paginated form, so the bare {authors} response silently
truncated to the first page with no total to signal more, capping the
Authors/Series screens at the first N entries.

Non-paginated requests now use limit=0 (return all, the existing ABS
contract in the store layer); explicitly paginated requests are
unchanged.

Co-Authored-By: Claude Fable 5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b1c9a08c-27c6-4029-8a95-dfefc0acae50

📥 Commits

Reviewing files that changed from the base of the PR and between 7a6daec and 5cb7242.

📒 Files selected for processing (1)
  • internal/audiobooks/media_store.go

📝 Walkthrough

Walkthrough

handleLibraryAuthors and handleLibrarySeries now cap non-paginated result sizes and warn when results are truncated. Access logging now redacts sensitive query parameters before logging and includes the user agent as a structured field. Author lookup now reads poster data from photo_path.

Changes

Pagination guardrails for library lists

Layer / File(s) Summary
Clamp unpaginated library results
internal/audiobooks/abs/libraries_handler.go
Adds slog logging, defines maximum sizes for unpaginated author and series requests, switches both handlers to readPagedQuery(..., 0), and clamps the effective limits before querying the store.
Warn on truncated non-paginated responses
internal/audiobooks/abs/libraries_handler.go
Logs a warning for non-paginated author and series requests when the store reports more items than were returned.

Access log query redaction

Layer / File(s) Summary
Sanitize logged query strings
internal/audiobooks/abs/access_log.go
Adds a helper that redacts token, apikey, and api_key values from request queries before logging.
Add query and user-agent fields
internal/audiobooks/abs/access_log.go
Extends access logs with a sanitized query field when present and a ua field from the User-Agent header.

Author photo lookup

Layer / File(s) Summary
Use photo_path for author poster data
internal/audiobooks/media_store.go
Selects photo_path for author lookups, scans it as a string, and assigns it directly to PosterPath while keeping not-found and wrapped error handling.

Estimated code review effort: 3 (Moderate) | ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: non-paginated ABS author and series requests are handled to return more complete results.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/abs-authors-return-all

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 56707a20f6

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

// cap) — clients like the official app fetch the whole list once and
// scroll it locally, so a server-side default limit silently truncates
// the Authors page. limit=0 means "return all".
limit, page := readPagedQuery(r, 0)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Treat limit-only author requests as unpaginated

When a client sends /api/libraries/{id}/authors?limit=100 without page (the handler below returns the bare non-paginated {authors: ...} shape unless both params are present), this call still passes limit=100 to ListLibraryAuthors. That response is truncated but carries no total/paging envelope, so clients cannot discover authors beyond the cap; match the pagination predicate when deciding whether to pass a limit.

Useful? React with 👍 / 👎.

A truly unbounded return-all crashes non-paginating mobile clients at
silo scale: a 250k-book library carries ~98k authors (15.5MB JSON) and
~32k series (each row embeds up to four minified book objects). Real
ABS never sees libraries this size, so its return-all contract has no
survival story for them.

Clamp the return-all form to 10k authors / 2k series and log a Warn
when a non-paginated request is truncated, so the cutoff is deliberate
and observable instead of a silent first-page mystery. Explicitly
paginated clients still page through the full set via the paged
envelope's total.

Co-Authored-By: Claude Fable 5 <[email protected]>
@Quick104

Quick104 commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor Author

Follow-up pushed: verified on a large dev audiobook library that true return-all (15.5MB) crashes a non-paginating client, so the return-all form is now clamped to 10k authors / 2k series with a Warn log on truncation. Paginated clients still reach the full set via the paged envelope.

Path-only debug lines can't distinguish paginated from non-paginated
list requests, which blocked diagnosing a client crash on /authors.
Log the query string with credential params redacted, plus the
user-agent to tell concurrent clients apart.

Co-Authored-By: Claude Fable 5 <[email protected]>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
internal/audiobooks/abs/libraries_handler.go (1)

345-458: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add test coverage for the new guardrail behavior.

The PR notes go test ./internal/audiobooks/... passed, but the diff doesn't appear to add tests for the new clamp/warning logic itself — e.g., non-paginated request exceeding maxUnpaginatedAuthors/maxUnpaginatedSeries gets clamped, the warning fires only on the intended path, and the page-without-limit edge case discussed above. These are exactly the kind of behaviors that regress silently.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/audiobooks/abs/libraries_handler.go` around lines 345 - 458, Add
test coverage for the new guardrail logic in handleLibraryAuthors and
handleLibrarySeries. Create cases that verify non-paginated requests are clamped
to maxUnpaginatedAuthors/maxUnpaginatedSeries, that the truncation warning is
emitted only when total exceeds the returned slice and page is absent, and that
the page-without-limit path behaves as intended. Use the existing handler
methods and the
readPagedQuery/accessFilterFromRequest/ListLibraryAuthors/ListLibrarySeries flow
so the tests lock in the new behavior and prevent silent regressions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@internal/audiobooks/abs/libraries_handler.go`:
- Around line 345-458: Add test coverage for the new guardrail logic in
handleLibraryAuthors and handleLibrarySeries. Create cases that verify
non-paginated requests are clamped to
maxUnpaginatedAuthors/maxUnpaginatedSeries, that the truncation warning is
emitted only when total exceeds the returned slice and page is absent, and that
the page-without-limit path behaves as intended. Use the existing handler
methods and the
readPagedQuery/accessFilterFromRequest/ListLibraryAuthors/ListLibrarySeries flow
so the tests lock in the new behavior and prevent silent regressions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 9c8ad08c-4895-457d-b0cb-236a4a76d8ce

📥 Commits

Reviewing files that changed from the base of the PR and between 56707a2 and 54114b0.

📒 Files selected for processing (1)
  • internal/audiobooks/abs/libraries_handler.go

@Quick104
Quick104 merged commit cd7e790 into main Jul 6, 2026
1 check passed
@Quick104
Quick104 deleted the fix/abs-authors-return-all branch July 6, 2026 13:57
Quick104 added a commit that referenced this pull request Jul 10, 2026
…ests (#317)

* fix(audiobooks): select photo_path in ABS author detail query

GetAuthorByID selected poster_path from the people table, but the
person-image column is photo_path, so every GET /api/authors/{id}
request failed with SQLSTATE 42703 and a 500. Since photo_path is
NOT NULL DEFAULT '', the nullable scan is also dropped.

Co-Authored-By: Claude Fable 5 <[email protected]>

* fix(audiobooks): return all authors/series for non-paginated ABS requests

Real ABS returns the FULL author list when the client sends no
limit/page — the official app and other clients fetch it once and
scroll locally. Silo applied a default limit (50 authors, 25 series)
to the non-paginated form, so the bare {authors} response silently
truncated to the first page with no total to signal more, capping the
Authors/Series screens at the first N entries.

Non-paginated requests now use limit=0 (return all, the existing ABS
contract in the store layer); explicitly paginated requests are
unchanged.

Co-Authored-By: Claude Fable 5 <[email protected]>

* fix(audiobooks): clamp non-paginated authors/series to a guardrail cap

A truly unbounded return-all crashes non-paginating mobile clients at
silo scale: a 250k-book library carries ~98k authors (15.5MB JSON) and
~32k series (each row embeds up to four minified book objects). Real
ABS never sees libraries this size, so its return-all contract has no
survival story for them.

Clamp the return-all form to 10k authors / 2k series and log a Warn
when a non-paginated request is truncated, so the cutoff is deliberate
and observable instead of a silent first-page mystery. Explicitly
paginated clients still page through the full set via the paged
envelope's total.

Co-Authored-By: Claude Fable 5 <[email protected]>

* feat(audiobooks): log sanitized query + user-agent in ABS access log

Path-only debug lines can't distinguish paginated from non-paginated
list requests, which blocked diagnosing a client crash on /authors.
Log the query string with credential params redacted, plus the
user-agent to tell concurrent clients apart.

Co-Authored-By: Claude Fable 5 <[email protected]>

---------

Co-authored-by: Claude Fable 5 <[email protected]>
@zZebrahz zZebrahz mentioned this pull request Sep 27, 2026
10 tasks done
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.

1 participant