Skip to content

fix(audiobooks): /api/authors/{id} 500 — select photo_path, not poster_path - #315

Merged
Quick104 merged 1 commit into
mainfrom
fix/abs-author-photo-path
Jul 6, 2026
Merged

Quick104 merged 1 commit into
mainfrom
fix/abs-author-photo-path

Conversation

@Quick104

@Quick104 Quick104 commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Every GET /api/authors/{id} request on the Audiobookshelf-compat API returned a 500. ABSMediaStore.GetAuthorByID selected poster_path from the people table, but the person-image column is photo_path, so the query always failed with SQLSTATE 42703 (column does not exist):

msg="abs author detail failed" err="abs_media_store: get author: ERROR: column \"poster_path\" does not exist (SQLSTATE 42703)"

Reported via an internal Discord thread by a user of a third-party ABS client; author detail pages failed to load.

Fix

Select photo_path instead. Since the column is NOT NULL DEFAULT '', the nullable *string scan is replaced with a plain string assigned directly to Author.PosterPath (empty stays empty, matching prior behavior).

Only the detail path was affected — author listing reads from the abs_audiobook_author_counts MV and does not touch this column.

Verification

  • go build ./internal/audiobooks/ and go vet ./internal/audiobooks/ pass.
  • Column name verified against migrations/sql/001_schema.sql (people.photo_path).

Disclosure

Implemented with Claude Code (AI-assisted); change reviewed against the schema.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Author details now load more reliably when viewed in the app.
    • Author images are now displayed consistently instead of being omitted when the stored image path is present.

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]>
@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: f61da8d9-7364-4c7f-a297-ad1aa1fa6878

📥 Commits

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

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

📝 Walkthrough

Walkthrough

The GetAuthorByID function was updated to query photo_path instead of nullable poster_path, scanning it into a non-null string and always populating PosterPath. Error handling now uses errors.Is(err, pgx.ErrNoRows) to detect missing rows.

Changes

Author Lookup Fix

Layer / File(s) Summary
Author query and poster path scanning
internal/audiobooks/media_store.go
Changed the SELECT query to fetch photo_path, scan it as a non-null string, unconditionally assign PosterPath, and use errors.Is for pgx.ErrNoRows detection.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Poem

A rabbit hopped through database rows,
Where nulls once hid, now clarity shows.
Photo paths scanned, no pointer in sight,
Errors checked properly, wrongs made right.
A tiny fix, but oh so bright! 🐰

🚥 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 states the author-detail API fix and the wrong column change, matching the main change in the PR.
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-author-photo-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: ed2e6b65be

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

row := s.Pool.QueryRow(ctx, `SELECT name, poster_path FROM people WHERE id = $1`, id)
if err := row.Scan(&name, &poster); err != nil {
var name, photo string
row := s.Pool.QueryRow(ctx, `SELECT name, photo_path FROM people WHERE id = $1`, id)

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 Gate author detail on accessible audiobooks

When the caller's AccessFilter excludes every audiobook for this person (for example a profile restricted to other libraries or a lower content rating), this lookup still returns the people row by id before any access predicate is applied; the later appendAudiobookAccessConditions only filters author.Books. Now that the query succeeds, /api/authors/{id} can return 200 with the author name and zero books for authors the profile cannot see, so the person lookup should be tied to at least one accessible audiobook and return ErrNotFound otherwise.

Useful? React with 👍 / 👎.

Quick104 added a commit that referenced this pull request Jul 6, 2026
@Quick104
Quick104 merged commit 885e819 into main Jul 6, 2026
3 checks passed
@Quick104
Quick104 deleted the fix/abs-author-photo-path branch July 6, 2026 13:57
Quick104 added a commit that referenced this pull request Jul 10, 2026
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]>
@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