Skip to content

fix(catalog): project air_timezone in episode catalog subquery - #24

Merged
Quick104 merged 1 commit into
mainfrom
claude/amazing-thompson-b2843d
May 29, 2026
Merged

Quick104 merged 1 commit into
mainfrom
claude/amazing-thompson-b2843d

Conversation

@Quick104

@Quick104 Quick104 commented May 29, 2026 •

Copy link
Copy Markdown
Contributor

Problem

GET /api/v1/catalog?source=query&type=episode&... returns HTTP 500 (Failed to resolve catalog) on dev, while movie and series scopes return 200.

Server log:

catalog: resolve failed  err_msg="hydrating episode catalog entry page: ERROR: column mi.air_timezone does not exist (SQLSTATE 42703)"

Root cause

Episode catalog hydration/preview run SELECT qualifiedListItemColumns("mi") FROM (episodeCatalogSelectBody) mi, where mi is a hand-written subquery rather than the physical media_items table.

fb10bde0 feat(calendar): show local episode airtimes added air_timezone to the shared column lists (itemColumns, qualifiedListItemColumns, the upsert) but did not add it to episodeCatalogSelectBody. The outer projection then referenced mi.air_timezone, which the subquery never projected → Postgres 42703.

42703 is not one of the codes episodeCatalogEntriesUnavailable treats as "fast path unavailable" (it only catches 42P01/42883), so the request errored with a 500 instead of degrading. movie/series query media_items directly, so the column is present for them and only episode scope broke. The air_timezone column itself exists in the DB (migration 162) — this was purely a code-level column-list mismatch, not a missing migration.

Fix

  • Project si.air_timezone in episodeCatalogSelectBody (internal/catalog/episode_catalog_source.go).
  • Add internal/catalog/episode_catalog_select_body_test.go: asserts the episode subquery exposes every column qualifiedListItemColumns("mi") reads off mi, so this drift (now the second air_* instance) fails at test time instead of in production.

Verification

  • New test fails on the pre-fix code (reports exactly [air_timezone]) and passes after the fix.
  • go build ./internal/catalog/ clean; full go test ./internal/catalog/ green; gofmt/go vet clean.
  • Confirmed the other qualifiedListItemColumns/qualifiedItemColumns callers (favorites, item_repo) use the physical media_items table, so no other hydration site has the same gap.

Go-only change; no web or migration changes.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Episode catalog now includes air timezone information in query results.
  • Tests

    • Added test to verify episode catalog query output includes all required data columns.

Review Change Stack

episodeCatalogSelectBody is the derived "mi" relation that episode catalog
hydration and preview read qualifiedListItemColumns("mi") from. The local
episode airtimes feature (fb10bde) added air_timezone to the shared column
lists but not to this hand-written subquery, so the outer projection
referenced mi.air_timezone, which the subquery never exposed.

Postgres returns SQLSTATE 42703 (undefined_column), which is not one of the
codes episodeCatalogEntriesUnavailable treats as "fast path unavailable" (it
only catches 42P01/42883), so episode catalog requests failed with HTTP 500
instead of degrading. movie and series scopes query media_items directly, so
the column is present there and only episode scope broke.

Add si.air_timezone to the subquery, and add a regression test asserting that
episodeCatalogSelectBody exposes every column qualifiedListItemColumns reads
off mi, so future additions to the shared column lists cannot silently drift
from the episode read model again.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented May 29, 2026 •

Copy link
Copy Markdown
Contributor

Caution

Review failed

Pull request was closed or merged during review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 04292746-8c67-4168-a857-1e1c13b84350

📥 Commits

Reviewing files that changed from the base of the PR and between 97eb83d and 88ac1a1.

📒 Files selected for processing (2)
  • internal/catalog/episode_catalog_select_body_test.go
  • internal/catalog/episode_catalog_source.go

📝 Walkthrough

Walkthrough

This PR adds si.air_timezone to the episode catalog SELECT projection and introduces a comprehensive test that validates the column is properly exposed. The test implements SQL parsing logic to verify that all required columns appear in the catalog query output.

Changes

Episode Catalog Timezone Column

Layer / File(s) Summary
Episode catalog column exposure validation test
internal/catalog/episode_catalog_select_body_test.go
A new test TestEpisodeCatalogSelectBodyExposesQualifiedColumns validates that the episode catalog SELECT projection includes all columns referenced by qualifiedListItemColumns("mi"). Supporting helpers parse the rendered SQL: extracting the top-level SELECT list, splitting on top-level commas while tracking parenthesis depth, and determining output column names from AS aliases or trailing identifiers. The test fails with a detailed message if any required column is missing.
Episode catalog source update
internal/catalog/episode_catalog_source.go
The episodeCatalogSelectBody SQL projection adds si.air_timezone as a returned field in catalog query results.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

A timezone flies into the catalog's song,
With helpers that parse SQL right and strong,
Each comma split with balance and care,
The columns all present, a test that's fair! 🐰✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 77.78% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: projecting air_timezone in the episode catalog subquery, which directly addresses the root cause of the bug.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 claude/amazing-thompson-b2843d

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

@Quick104
Quick104 merged commit 202509b into main May 29, 2026
1 check was pending
@Quick104
Quick104 deleted the claude/amazing-thompson-b2843d branch May 29, 2026 15:55
Quick104 added a commit to thezak48/silo-server that referenced this pull request Jun 7, 2026
…mpson-b2843d

fix(catalog): project air_timezone in episode catalog subquery
Quick104 added a commit that referenced this pull request Jun 11, 2026
fix(catalog): project air_timezone in episode catalog subquery
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