Repository navigation
feat: slack_installations table type + Supabase lib - #354
Conversation
… tests Add database types, CRUD operations (select by id/org, select by team id, upsert on team id conflict, delete by org), and unit tests for the slack_installations table to support Slack Marketplace distribution. Co-Authored-By: Paperclip <noreply@paperclip.ing>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughFour new database operation modules are added to Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 1✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
lib/supabase/slack_installations/selectSlackInstallation.ts (1)
23-25: Same error handling inconsistency asselectSlackInstallationByTeamId.Both select functions silently return
nullon errors while delete/upsert throw. For maintainability, align the error handling strategy across this module.♻️ Suggested fix
if (error) { - return null; + throw new Error(`Failed to select slack installation: ${error.message}`); }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@lib/supabase/slack_installations/selectSlackInstallation.ts` around lines 23 - 25, The selectSlackInstallation function currently returns null on database errors while other functions (e.g., selectSlackInstallationByTeamId, deleteSlackInstallation, upsertSlackInstallation) throw errors; update selectSlackInstallation's error handling to match the module: when the Supabase query returns an error, throw or re-throw that error (including its message) instead of returning null so callers receive consistent failure behavior; locate the error-check branch inside selectSlackInstallation and replace the silent-return with throwing the received error (or wrapping it with context) to align with the other CRUD functions.lib/supabase/slack_installations/selectSlackInstallationByTeamId.ts (1)
20-22: Inconsistent error handling: consider throwing or logging instead of silent null.This function returns
nullon error, conflating "not found" with "error occurred." In contrast,deleteSlackInstallation.tsthrows on error. This inconsistency can make debugging harder—callers can't distinguish between a missing record and a database failure.Consider either:
- Throwing on error (for consistency with delete/upsert)
- At minimum, logging the error before returning null
♻️ Option 1: Throw on error for consistency
if (error) { - return null; + throw new Error(`Failed to select slack installation by team ID: ${error.message}`); }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@lib/supabase/slack_installations/selectSlackInstallationByTeamId.ts` around lines 20 - 22, The function selectSlackInstallationByTeamId currently returns null when the database call sets error, which hides real failures and conflates "not found" with "query error"; update selectSlackInstallationByTeamId to mirror deleteSlackInstallation's behavior by throwing the received error (or at minimum logging it) when the local variable error is truthy, while still returning null only when the query succeeds but yields no rows—ensure you reference the same error object in the thrown exception/log message so callers can differentiate actual DB failures from a missing record.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@lib/supabase/slack_installations/selectSlackInstallation.ts`:
- Around line 23-25: The selectSlackInstallation function currently returns null
on database errors while other functions (e.g., selectSlackInstallationByTeamId,
deleteSlackInstallation, upsertSlackInstallation) throw errors; update
selectSlackInstallation's error handling to match the module: when the Supabase
query returns an error, throw or re-throw that error (including its message)
instead of returning null so callers receive consistent failure behavior; locate
the error-check branch inside selectSlackInstallation and replace the
silent-return with throwing the received error (or wrapping it with context) to
align with the other CRUD functions.
In `@lib/supabase/slack_installations/selectSlackInstallationByTeamId.ts`:
- Around line 20-22: The function selectSlackInstallationByTeamId currently
returns null when the database call sets error, which hides real failures and
conflates "not found" with "query error"; update selectSlackInstallationByTeamId
to mirror deleteSlackInstallation's behavior by throwing the received error (or
at minimum logging it) when the local variable error is truthy, while still
returning null only when the query succeeds but yields no rows—ensure you
reference the same error object in the thrown exception/log message so callers
can differentiate actual DB failures from a missing record.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 21050662-b511-49d1-9101-925ad2143f63
⛔ Files ignored due to path filters (5)
lib/supabase/slack_installations/__tests__/deleteSlackInstallation.test.tsis excluded by!**/*.test.*,!**/__tests__/**and included bylib/**lib/supabase/slack_installations/__tests__/selectSlackInstallation.test.tsis excluded by!**/*.test.*,!**/__tests__/**and included bylib/**lib/supabase/slack_installations/__tests__/selectSlackInstallationByTeamId.test.tsis excluded by!**/*.test.*,!**/__tests__/**and included bylib/**lib/supabase/slack_installations/__tests__/upsertSlackInstallation.test.tsis excluded by!**/*.test.*,!**/__tests__/**and included bylib/**types/database.types.tsis excluded by none and included by none
📒 Files selected for processing (4)
lib/supabase/slack_installations/deleteSlackInstallation.tslib/supabase/slack_installations/selectSlackInstallation.tslib/supabase/slack_installations/selectSlackInstallationByTeamId.tslib/supabase/slack_installations/upsertSlackInstallation.ts
Code Review — api#354SummaryAdds Supabase lib functions and types for the CI Status
Branch Status
CLEAN Code Assessment
Issues Found💡 Nit:
|
Summary
slack_installationstable type definition totypes/database.types.ts(Row, Insert, Update, Relationships)lib/supabase/slack_installations/:selectSlackInstallation.ts— select by id or organization_idselectSlackInstallationByTeamId.ts— select by slack_team_id (used in artist resolution)upsertSlackInstallation.ts— upsert on slack_team_id conflictdeleteSlackInstallation.ts— delete by organization_idDepends on: database#14 (migration must be applied first)
Test plan
Relates to: REC-20 (parent: REC-19 Slack Marketplace Distribution)
🤖 Generated with Claude Code