Skip to content

feat(audiobooks): emit non-null imagePath for photo-bearing ABS authors - #316

Merged
Quick104 merged 3 commits into
mainfrom
feat/abs-author-image-path
Jul 6, 2026
Merged

Quick104 merged 3 commits into
mainfrom
feat/abs-author-image-path

Conversation

@Quick104

@Quick104 Quick104 commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

Problem

ABS-compat author responses always emitted "imagePath": null (list and detail alike), even though GET /api/authors/{id}/image works and a meaningful share of audiobook authors have a people.photo_path. ABS clients treat a non-null imagePath as the cue to fetch the author image endpoint — with it hardcoded to null, no client ever showed an author photo.

Fix

Emit a non-null imagePath whenever the person has a photo. Real ABS stores a server-local filesystem path there and clients never dereference it directly (they call /api/authors/{id}/image), so a synthetic ABS-shaped path (/metadata/authors/{id}.jpg) is emitted as the flag.

  • Detail (authorToABS): flag comes from Author.PosterPath, which the store already loads.
  • List (handleLibraryAuthors): new AuthorSummary.HasPhoto. The MV path LEFT JOINs people at read time — the abs_audiobook_author_counts MV carries no photo column, and a read-time join keeps photo presence current instead of stale until the next REFRESH. The live fallback selects photo_path <> '' off its existing people join (allowed under GROUP BY p.id by PK functional dependency).

The filter-data and search author buckets don't emit imagePath today and are unchanged.

Includes the commit from #315 (GetAuthorByID column fix) — the detail path depends on it; this PR reduces to one commit once #315 merges.

Verification

  • go build / go vet / go test ./internal/audiobooks/... pass; handler tests now assert non-null imagePath for photo-bearing authors (detail + list) and null for authors without.
  • Both new SQL shapes validated against a live database (MV join and live GROUP BY variant).
  • Not yet exercised on a running deployment; after the next dev deploy, author list/detail should return non-null imagePath for photo-bearing authors, which ABS clients follow with GET /api/authors/{id}/image (already verified to 302 to the stored photo).

Disclosure

Implemented with Claude Code (AI-assisted).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Author lists and author detail responses now include photo availability, and authors with photos can return an image path.
  • Bug Fixes
    • Improved author image handling so photo-bearing authors display an image consistently across library and detail views.
  • Tests
    • Updated coverage to verify image path behavior for authors with and without photos.

Quick104 and others added 3 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]>
Author responses always emitted imagePath: null, so ABS clients never
fetched /api/authors/{id}/image even though it works and ~7% of
audiobook authors have a people.photo_path. Real ABS puts a server-local
filesystem path in imagePath and clients treat any non-null value as the
cue to fetch the image endpoint, so a synthetic ABS-shaped path is
emitted whenever the person has a photo.

The detail path reads the flag from Author.PosterPath. The list path
carries a new AuthorSummary.HasPhoto: the MV query LEFT JOINs people at
read time (photo presence stays current instead of stale until the next
REFRESH) and the live fallback selects photo_path alongside its existing
people join.

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: 7f186440-6d73-47e2-a2e6-8c785e6d37a3

📥 Commits

Reviewing files that changed from the base of the PR and between 7cc0b32 and b37dcd4.

📒 Files selected for processing (5)
  • internal/audiobooks/abs/author_series_handler.go
  • internal/audiobooks/abs/author_series_handler_test.go
  • internal/audiobooks/abs/handler.go
  • internal/audiobooks/abs/libraries_handler.go
  • internal/audiobooks/media_store.go

📝 Walkthrough

Walkthrough

Adds a HasPhoto boolean field to AuthorSummary and populates Author.PosterPath directly from photo_path in data store queries. ABS handlers now conditionally emit imagePath in author JSON based on photo presence, with corresponding query joins and test updates.

Changes

Author photo flag propagation

Layer / File(s) Summary
Data store: photo detection and PosterPath population
internal/audiobooks/media_store.go
ListLibraryAuthors (MV and live paths) compute a hasPhoto boolean via joins/COALESCE checks and populate HasPhoto; GetAuthorByID selects photo_path and sets PosterPath directly, removing prior nullable-pointer handling.
AuthorSummary contract and ABS serialization
internal/audiobooks/abs/handler.go, internal/audiobooks/abs/author_series_handler.go, internal/audiobooks/abs/libraries_handler.go
AuthorSummary gains a HasPhoto field; authorObjectABS accepts a hasPhoto parameter and conditionally sets a synthetic imagePath; call sites pass photo presence through.
Test fixtures and assertions
internal/audiobooks/abs/author_series_handler_test.go
Test stubs add Books data and HasPhoto: true, with new assertions checking imagePath is non-null for photo-bearing authors and null otherwise.

Estimated code review effort: 2 (Simple) | ~15 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant LibrariesHandler
  participant AuthorSeriesHandler
  participant MediaStore
  Client->>LibrariesHandler: request library authors
  LibrariesHandler->>MediaStore: ListLibraryAuthors
  MediaStore-->>LibrariesHandler: AuthorSummary with HasPhoto
  LibrariesHandler->>AuthorSeriesHandler: authorObjectABS(a.HasPhoto)
  AuthorSeriesHandler-->>Client: author JSON with conditional imagePath
Loading
🚥 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 summarizes the main change: ABS authors with photos now emit a non-null imagePath.
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 feat/abs-author-image-path

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: b37dcd4a11

ℹ️ 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".

// The MV carries no photo column; join people at read time so photo
// presence is always current instead of stale until the next REFRESH.
dataSQL := `SELECT c.person_id, c.name, c.num_books, c.added_at,
COALESCE(p.photo_path, '') <> ''

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 '-' as a missing author photo

When people.photo_path is the "-" sentinel, this predicate marks the author as photo-bearing and the ABS list emits a non-null imagePath; the detail path has the same issue because GetAuthorByID copies raw photo_path and authorToABS checks only != "". The repo treats "-" as no photo elsewhere (internal/api/handlers/people.go:357, internal/catalog/person_repo.go:319), so ABS clients will be prompted to fetch /api/authors/{id}/image for authors with no real image and get a broken/404 image. Please exclude "-" in the has-photo checks.

Useful? React with 👍 / 👎.

@Quick104
Quick104 merged commit a5b23da into main Jul 6, 2026
3 checks passed
@Quick104
Quick104 deleted the feat/abs-author-image-path branch July 6, 2026 14:45
Quick104 added a commit that referenced this pull request Jul 10, 2026
…rs (#316)

* 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]>

* feat(audiobooks): emit non-null imagePath for photo-bearing ABS authors

Author responses always emitted imagePath: null, so ABS clients never
fetched /api/authors/{id}/image even though it works and ~7% of
audiobook authors have a people.photo_path. Real ABS puts a server-local
filesystem path in imagePath and clients treat any non-null value as the
cue to fetch the image endpoint, so a synthetic ABS-shaped path is
emitted whenever the person has a photo.

The detail path reads the flag from Author.PosterPath. The list path
carries a new AuthorSummary.HasPhoto: the MV query LEFT JOINs people at
read time (photo presence stays current instead of stale until the next
REFRESH) and the live fallback selects photo_path alongside its existing
people join.

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

---------

Co-authored-by: Claude Fable 5 <[email protected]>
@zZebrahz zZebrahz mentioned this pull request Nov 25, 2026
4 of 13 tasks
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