refactor(types): tighten common any/unknown usages with shared helpers - #2766
Conversation
Add reusable error helpers and replace easy bodyRaw/catch/Record any patterns across frontend stores and backend public APIs without over-typing Chart.js, SSO, or CLI UI paths. Co-authored-by: Martin DONADIEU <martindonadieu@gmail.com>
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 11 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. 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, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThe PR strengthens TypeScript contracts across frontend components, stores, services, Supabase functions, request handlers, and notification utilities. It also centralizes unknown-error parsing, narrows webhook validation, and adds runtime validation for realtime-feed preferences. ChangesFrontend typing and error handling
Backend typing and request flows
Estimated code review effort: 3 (Moderate) | ~30 minutes Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Comment |
Merging this PR will not alter performance
Comparing Footnotes
|
Keep only the helpers currently used so knip deadcode checks pass. Co-authored-by: Martin DONADIEU <martindonadieu@gmail.com>
Co-authored-by: Martin DONADIEU <martindonadieu@gmail.com>
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_897e9951-bfa3-4e0a-949b-8b0af94ae2e5) |
There was a problem hiding this comment.
Stale comment
Risk: medium. Left a non-blocking comment — Cursor Bugbot did not complete successfully (skipped: usage limit), and this 54-file typing refactor across backend public APIs/webhooks/RBAC and frontend stores exceeds the low-risk auto-approve threshold. Reviewers were assigned for human review.
Sent by Cursor Approval Agent: Pull Request Approver External
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/components/comp_def.ts`:
- Around line 51-56: Update the generic default on the Tab interface to TableRow
instead of unknown, preserving the existing onClick callback behavior for
unparameterized Tab usages while leaving explicitly parameterized Tab types
unchanged.
In `@src/services/supabase.ts`:
- Around line 690-691: Update the native package metadata handling in the
version-fetching flow so missing or null remoteNativePackages.version or
native_packages remains a failure instead of defaulting to an empty array.
Validate that native_packages is an actual array, reject or propagate the
missing-metadata error through the existing failure path, and call
convertNativePackages only with validated array data.
In `@src/stores/adminDashboard.ts`:
- Around line 161-170: Update fetchStats<T> to default to unknown instead of
any, and stop treating cached or fetched unvalidated data as arbitrary T. Add
metric-specific response types with runtime validation before caching and
returning stats, preserving the existing cache behavior while requiring callers
to narrow unknown results when no specific type is supplied.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 4dfad5b1-5e31-40c0-b5ad-7716e07971f7
📒 Files selected for processing (54)
src/components/comp_def.tssrc/components/dashboard/AppAccess.vuesrc/components/permissions/ChannelAccessPanel.vuesrc/components/tables/AccessTable.vuesrc/composables/useRealtimeCLIFeed.tssrc/pages/settings/organization/Members.vuesrc/services/apikeys.tssrc/services/logAs.tssrc/services/staleAssetErrors.tssrc/services/supabase.tssrc/stores/adminDashboard.tssrc/stores/main.tssrc/stores/organization.tssrc/stores/webhooks.tssrc/utils/errors.tssupabase/functions/_backend/plugin_runtime/utils/bento.tssupabase/functions/_backend/plugin_runtime/utils/hono.tssupabase/functions/_backend/plugin_runtime/utils/org_email_notifications.tssupabase/functions/_backend/plugin_runtime/utils/plugin_notification_queue.tssupabase/functions/_backend/plugin_runtime/utils/posthog.tssupabase/functions/_backend/plugin_runtime/utils/queryHelpers.tssupabase/functions/_backend/private/admin_credits.tssupabase/functions/_backend/private/credits.tssupabase/functions/_backend/private/invite_existing_user_to_org.tssupabase/functions/_backend/private/role_bindings.tssupabase/functions/_backend/public/apikey/post.tssupabase/functions/_backend/public/apikey/put.tssupabase/functions/_backend/public/app/post.tssupabase/functions/_backend/public/app/put.tssupabase/functions/_backend/public/build/request.tssupabase/functions/_backend/public/organization/audit.tssupabase/functions/_backend/public/organization/get.tssupabase/functions/_backend/public/organization/members/delete.tssupabase/functions/_backend/public/organization/members/get.tssupabase/functions/_backend/public/organization/members/post.tssupabase/functions/_backend/public/organization/post.tssupabase/functions/_backend/public/organization/put.tssupabase/functions/_backend/public/webhooks/delete.tssupabase/functions/_backend/public/webhooks/deliveries.tssupabase/functions/_backend/public/webhooks/get.tssupabase/functions/_backend/public/webhooks/index.tssupabase/functions/_backend/public/webhooks/post.tssupabase/functions/_backend/public/webhooks/put.tssupabase/functions/_backend/public/webhooks/test.tssupabase/functions/_backend/utils/bento.tssupabase/functions/_backend/utils/cron_email_stats.tssupabase/functions/_backend/utils/errors.tssupabase/functions/_backend/utils/hono.tssupabase/functions/_backend/utils/org_email_notifications.tssupabase/functions/_backend/utils/platform_admin_access.tssupabase/functions/_backend/utils/plugin_notification_queue.tssupabase/functions/_backend/utils/posthog.tssupabase/functions/_backend/utils/queryHelpers.tssupabase/functions/_backend/utils/webhook.ts
🔗 Linked repositories identified
CodeRabbit considers these linked repositories for cross-repo context during reviews:
Cap-go/capacitor-updater(manual)
Default Tab to TableRow for unparameterized callbacks, restore missing native_packages failure path, and keep admin fetchStats polymorphic without an unchecked generic default. Co-authored-by: Martin DONADIEU <martindonadieu@gmail.com>
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_0cc432ca-4bcc-4e21-bceb-952c5fa8af5c) |
There was a problem hiding this comment.
Stale comment
Risk: medium. Left a non-blocking comment — Cursor Bugbot did not complete successfully (skipped: usage limit), and this broad typing refactor across public APIs, webhooks, and RBAC exceeds the low-risk auto-approve threshold. Reviewers are already assigned for human review.
Sent by Cursor Approval Agent: Pull Request Approver External
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/services/supabase.ts`:
- Around line 690-694: Update the native package parsing flow before
convertNativePackages to require nativePackages to be an array, and validate
each item has the expected name and version fields before conversion. Keep the
existing parsing error for invalid metadata and only call convertNativePackages
with validated package entries.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 031c27c9-0497-43f7-8854-9a3dc1637c86
📒 Files selected for processing (3)
src/components/comp_def.tssrc/services/supabase.tssrc/stores/adminDashboard.ts
🔗 Linked repositories identified
CodeRabbit considers these linked repositories for cross-repo context during reviews:
Cap-go/capacitor-updater(manual)
Reject non-array remote metadata instead of only checking truthiness. Co-authored-by: Martin DONADIEU <martindonadieu@gmail.com>
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_35a5aefe-ea40-47a0-9e63-39cdb061f1fb) |
There was a problem hiding this comment.
Stale comment
Risk: medium. Left a non-blocking comment — Cursor Bugbot did not complete successfully (skipped: usage limit), and this broad typing refactor across public APIs, webhooks, and RBAC exceeds the low-risk auto-approve threshold. Reviewers are already assigned for human review.
Sent by Cursor Approval Agent: Pull Request Approver External
Replace recursive Merge/Concrete/ArrayElement helpers with simple indexed Supabase Returns[number] aliases and delete services/types.ts. Co-authored-by: Martin DONADIEU <martindonadieu@gmail.com>
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_9340cf0b-cb1b-4c09-bc5a-fd9226e4cfff) |
There was a problem hiding this comment.
Stale comment
Risk: medium. Left a non-blocking comment — Cursor Bugbot did not complete successfully (skipped: usage limit), and this broad typing refactor across public APIs, webhooks, and RBAC exceeds the low-risk auto-approve threshold. Reviewers are already assigned for human review.
Sent by Cursor Approval Agent: Pull Request Approver External
Co-authored-by: Martin DONADIEU <martindonadieu@gmail.com>
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_08a06f8f-27f8-46dc-a4ab-28bcf36e08e2) |
There was a problem hiding this comment.
Stale comment
Risk: medium. Left a non-blocking comment — Cursor Bugbot did not complete successfully (skipped: usage limit), and this broad typing refactor across public APIs, webhooks, and RBAC exceeds the low-risk auto-approve threshold. Reviewers are already assigned for human review.
Sent by Cursor Approval Agent: Pull Request Approver External
Co-authored-by: Martin DONADIEU <martindonadieu@gmail.com>
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_5b2f5441-bf97-483c-a19d-e984cdc8e350) |
There was a problem hiding this comment.
Stale comment
Risk: medium. Left a non-blocking comment — Cursor Bugbot did not complete successfully (skipped: usage limit), and this broad typing refactor across public APIs, webhooks, and RBAC exceeds the low-risk auto-approve threshold. Reviewers are already assigned for human review.
Sent by Cursor Approval Agent: Pull Request Approver External
Co-authored-by: Martin DONADIEU <martindonadieu@gmail.com>
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_ba7f6d5a-b36e-4a5f-ae3c-e5b6db790193) |
There was a problem hiding this comment.
Risk: medium. Left a non-blocking comment — Cursor Bugbot did not complete successfully (skipped: usage limit), and this broad typing refactor across public APIs, webhooks, and RBAC exceeds the low-risk auto-approve threshold. Reviewers are already assigned for human review.
Sent by Cursor Approval Agent: Pull Request Approver External
Co-authored-by: Martin DONADIEU <martindonadieu@gmail.com>
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_c99b72eb-34d2-4573-8409-5f906a9c26fd) |
|





Summary (AI generated)
src/utils/errors.tsandsupabase/functions/_backend/utils/errors.tsand reused them across stores/components/backend catch paths.bodyRaw: anywithunknown, narrowed HonoContextgenerics, and typed webhook event checks viaisWebhookEventType.Merge/Concrete/ArrayElementhelpers insrc/services/types.tsand replaced call sites with simple SupabaseReturns[number]aliases / intersections.Motivation (AI generated)
There were hundreds of
any/unknownusages, plus a homemade deepMergeutility that forced expensive recursive type instantiation. Focusing on reusable helpers and deleting our own slow types improves type safety and compile cost without rewriting Supabase-generated types.Business Impact (AI generated)
Fewer silent type holes in API request bodies and error handling, with faster/safer frontend typechecking by dropping recursive homemade utilities.
Test Plan (AI generated)
bun typecheck(cli + backend + frontend)bun lint/bun lint:backend/bun lint:deadcodeRun testsgreen on latest commitCould not type (too hard / out of scope) (AI generated)
Left alone on purpose:
null as any) and many RPC/as anyjoinsrpc as anycastscaches, Drizzle/pg aliasesorg: anypathsas anymocksTableRow = anydefault kept for unparameterized tablesGenerated with AI
Summary by CodeRabbit
Bug Fixes
Refactor