Skip to content

feat: slack_installations table type + Supabase lib - #354

Merged
recoup-coding-agent merged 1 commit into
testfrom
feature/slack-installations-table
Mar 27, 2026
Merged

recoup-coding-agent merged 1 commit into
testfrom
feature/slack-installations-table

Conversation

@recoup-coding-agent

@recoup-coding-agent recoup-coding-agent commented Mar 27, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Added slack_installations table type definition to types/database.types.ts (Row, Insert, Update, Relationships)
  • Created 4 Supabase lib functions in lib/supabase/slack_installations/:
    • selectSlackInstallation.ts — select by id or organization_id
    • selectSlackInstallationByTeamId.ts — select by slack_team_id (used in artist resolution)
    • upsertSlackInstallation.ts — upsert on slack_team_id conflict
    • deleteSlackInstallation.ts — delete by organization_id
  • 12 unit tests covering all success and error paths

Depends on: database#14 (migration must be applied first)

Test plan

  • All 12 unit tests pass
  • No new lint errors introduced
  • Formatting verified with Prettier
  • Merge database#14 migration first

Relates to: REC-20 (parent: REC-19 Slack Marketplace Distribution)

🤖 Generated with Claude Code

… 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>
@vercel

vercel Bot commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

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

Project Deployment Actions Updated (UTC)
recoup-api Ready Ready Preview Mar 27, 2026 1:48pm

Request Review

@coderabbitai

coderabbitai Bot commented Mar 27, 2026 •

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Four new database operation modules are added to lib/supabase/slack_installations/ for managing Slack installation records, providing delete, select, select-by-team-id, and upsert functionality against the slack_installations table via the Supabase client.

Changes

Cohort / File(s) Summary
Slack Installations Database Operations
lib/supabase/slack_installations/deleteSlackInstallation.ts, lib/supabase/slack_installations/selectSlackInstallation.ts, lib/supabase/slack_installations/selectSlackInstallationByTeamId.ts, lib/supabase/slack_installations/upsertSlackInstallation.ts
Added four new database operation functions: deleteSlackInstallation() removes records by organization ID; selectSlackInstallation() queries by either ID or organization ID; selectSlackInstallationByTeamId() queries by Slack team ID; upsertSlackInstallation() performs insert-or-update with slack_team_id as conflict target. All include consistent error handling and return appropriate Slack installation types.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🔗 Slack installations now take flight,
Database ops clean and tight,
Delete, select, and upsert with care,
SOLID principles everywhere! 🚀

🚥 Pre-merge checks | ✅ 1
✅ Passed checks (1 passed)
Check name Status Explanation
Solid & Clean Code ✅ Passed Four new Supabase functions demonstrate solid SOLID principles adherence with single responsibilities, clear naming, and consistent error handling patterns matching existing codebase.

✏️ 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 feature/slack-installations-table

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.

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (2)
lib/supabase/slack_installations/selectSlackInstallation.ts (1)

23-25: Same error handling inconsistency as selectSlackInstallationByTeamId.

Both select functions silently return null on 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 null on error, conflating "not found" with "error occurred." In contrast, deleteSlackInstallation.ts throws on error. This inconsistency can make debugging harder—callers can't distinguish between a missing record and a database failure.

Consider either:

  1. Throwing on error (for consistency with delete/upsert)
  2. 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

📥 Commits

Reviewing files that changed from the base of the PR and between 79f5e0a and 72b0a4e.

⛔ Files ignored due to path filters (5)
  • lib/supabase/slack_installations/__tests__/deleteSlackInstallation.test.ts is excluded by !**/*.test.*, !**/__tests__/** and included by lib/**
  • lib/supabase/slack_installations/__tests__/selectSlackInstallation.test.ts is excluded by !**/*.test.*, !**/__tests__/** and included by lib/**
  • lib/supabase/slack_installations/__tests__/selectSlackInstallationByTeamId.test.ts is excluded by !**/*.test.*, !**/__tests__/** and included by lib/**
  • lib/supabase/slack_installations/__tests__/upsertSlackInstallation.test.ts is excluded by !**/*.test.*, !**/__tests__/** and included by lib/**
  • types/database.types.ts is excluded by none and included by none
📒 Files selected for processing (4)
  • lib/supabase/slack_installations/deleteSlackInstallation.ts
  • lib/supabase/slack_installations/selectSlackInstallation.ts
  • lib/supabase/slack_installations/selectSlackInstallationByTeamId.ts
  • lib/supabase/slack_installations/upsertSlackInstallation.ts

@recoup-coding-agent

Copy link
Copy Markdown
Collaborator Author

Code Review — api#354

Summary

Adds Supabase lib functions and types for the slack_installations table: select (by id/org), selectByTeamId, upsert, and delete. Includes 12 unit tests and type definitions.

CI Status

Check Status
test ✅ success
format ✅ success
Vercel ✅ success
CodeRabbit ✅ success

Branch Status

  • mergeable_state: clean — branch is up to date with test ✅

CLEAN Code Assessment

  • SRP: ✅ One function per file
  • DRY: ✅ Follows lib/supabase/[table]/[function].ts pattern
  • YAGNI: ✅ Only needed CRUD operations
  • OCP: ✅ New module, no modifications to existing code
  • Naming: ✅ Follows conventions (select*, upsert*, delete*)

Issues Found

💡 Nit: selectSlackInstallation silently swallows errors

Returns null on error — consistent with other select functions in the codebase but makes it impossible for callers to distinguish "not found" from "query failed."

Security

  • ✅ No raw SQL — all queries through Supabase client
  • ✅ No secrets in code
  • ✅ Type-safe with generated types

Test Coverage

  • ✅ 12 tests across 4 functions covering happy path, errors, and null cases

Verdict: approve

Clean, well-structured code following all project conventions. No blocking issues.

Note: This PR depends on database#14 being merged first (migration must exist before these functions work). database#14 currently has requested changes (RLS policy bug).

@recoup-coding-agent
recoup-coding-agent merged commit b3c1dd2 into test Mar 27, 2026
2 checks passed
sweetmantech added a commit that referenced this pull request Mar 27, 2026
sweetmantech added a commit that referenced this pull request Mar 27, 2026

This branch was successfully deployed

1 active deployment
Preview — 72b0a4ea Deployed Mar 27, 2026 by vercel[bot]
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