Skip to content

fix: catalog-songs artistName filter must restrict rows (fixes empty valuation catalogs)#688

Open
sweetmantech wants to merge 2 commits into
testfrom
fix/catalog-songs-artistname-restrict
Open

fix: catalog-songs artistName filter must restrict rows (fixes empty valuation catalogs)#688
sweetmantech wants to merge 2 commits into
testfrom
fix/catalog-songs-artistname-restrict

Conversation

@sweetmantech

@sweetmantech sweetmantech commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

The bug (why valuation catalogs render empty)

A warm lead lands on /catalogs/{id}; the chat's useArtistCatalogSongs filters by the active sidebar artist and falls back to unfiltered only when the filtered query returns total_count === 0.

#681's LEFT join broke that filter. With song_artists/accounts LEFT-joined, a non-matching artistName .eq no longer drops rows — it just nulls the embed. So GET /api/catalogs/songs?...&artistName=<active artist> on a catalog by a different artist returns every row with artists: [null] and a non-zero count. The chat's fallback never fires (count ≠ 0), so:

  • isCompleteSong fails on the [null] artist → all songs hidden ("Found N songs", empty list)
  • the row renderer hits null.nameCannot read properties of null (reading 'name') crash on "show all"

This masks the now-complete data from #684 (artists) + #687 (notes).

Fix

  • When artistName is provided, inner-join song_artists/accounts so the filter restricts rows. A non-matching artist now returns 0 → the chat's existing fallback refetches the full catalog → songs render with their real artists.
  • When no artistName, keep the LEFT join (api#681) so artist-less tracks still surface.
  • Defensive: .filter(Boolean) the accounts so artists is never [null].

Verification (preview, real DB)

Greg Mendez catalog ccf07c48 (23 complete songs):

  • artistName=Gatsby Grace (non-matching) → before: 23 with [null]; after: 0 → chat falls back.
  • artistName=Greg Mendez (matching) → 23 with real artists.
  • no artistName → 23 with artists (LEFT preserved).

(Preview curl results in a follow-up comment.) Root-cause fix for recoupable/chat#1801.

🤖 Generated with Claude Code


Summary by cubic

Fixes empty catalogs and a row crash in chat by making the catalog songs artistName filter restrict rows.

  • Bug Fixes

    • Inner-join song_artists and accounts when artistName is set; keep LEFT joins when not filtering.
    • Filter out null accounts so artists is never [null].
    • Prevents hidden songs and the null.name crash while keeping artist-less tracks visible with no filter.
  • Refactors

    • Prettier-format selectCatalogSongsWithArtists for consistency.

Written for commit adc4018. Summary will update on new commits.

Review in cubic

… embed)

api#681's LEFT join broke the artistName filter: a non-matching .eq on the
LEFT-joined song_artists/accounts no longer drops rows, it just nulls the
embed -> the query returns every catalog song with artists:[null] and a
non-zero count. In chat, useArtistCatalogSongs filters by the active
sidebar artist and falls back to unfiltered only when total_count===0;
because the broken filter returned count>0 with [null] artists, the
fallback never fired -> isCompleteSong hid every song and the row renderer
crashed on null.name.

When artistName is provided, inner-join song_artists/accounts so the
filter restricts rows (non-matching artist -> 0 rows -> chat falls back to
the full catalog). Without a filter, keep the LEFT join so artist-less
captured tracks still surface (api#681). Also filter null accounts so the
artists array is never [null].

Verified on preview; root-cause fix for recoupable/chat#1801.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
api Ready Ready Preview Jun 19, 2026 12:39am

Request Review

@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@sweetmantech, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 48 minutes and 27 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a0008f30-c096-4a51-b4df-e9e8fa6777c8

📥 Commits

Reviewing files that changed from the base of the PR and between 0e42d02 and adc4018.

📒 Files selected for processing (1)
  • lib/supabase/catalog_songs/selectCatalogSongsWithArtists.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/catalog-songs-artistname-restrict

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@cubic-dev-ai cubic-dev-ai 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.

0 issues found across 1 file (changes from recent commits).

Requires human review: Business logic change to database query joins based on artistName parameter. While well-motivated, it alters core data retrieval logic and could introduce regressions in song filtering.

Re-trigger cubic

@sweetmantech

Copy link
Copy Markdown
Contributor Author

Preview verification ✅

Preview api-kn3ew2try-recoup.vercel.app, Greg Mendez catalog ccf07c48 (23 complete songs):

Query Before (#681 LEFT) After (#688)
artistName=Gatsby Grace (non-matching) total_count: 23, artists:[null] total_count: 0 ✅ → chat fallback fires
artistName=Greg Mendez (matching) 23 total_count: 23, artists:['Greg Mendez']
no artistName 23 ([null] possible) total_count: 23, no [null], ['Greg Mendez']

So a non-matching active artist now returns 0 → the chat's existing total_count === 0 fallback refetches the full catalog → the complete songs (artists from #684 + notes from #687) render, and the null.name crash is gone.

tsc + eslint + prettier clean. Root-cause fix for recoupable/chat#1801.

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