Skip to content

feat(functions)!: make FunctionException a sealed class - #1723

Merged
spydon merged 1 commit into
supabase:mainfrom
YadneshTeli:feat/sealed-function-exception
Aug 17, 2026
Merged

spydon merged 1 commit into
supabase:mainfrom
YadneshTeli:feat/sealed-function-exception

Conversation

@YadneshTeli

@YadneshTeli YadneshTeli commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

Description

Makes FunctionException a sealed class in packages/functions_client/lib/src/types.dart so consumers can perform compile-time checked exhaustive switch expressions over all Edge Function failure modes:

  • FunctionsFetchException: Network/transport error before reaching the Edge Function.
  • FunctionsApiException (formerly FunctionsHttpException, renamed in refactor!: spell out abbreviations in the public API #1712): Edge Function returned a non-2xx status code.
  • FunctionsRelayException: Error returned by the Supabase relay (x-relay-error).

Example:

try {
  await supabase.functions.invoke('hello');
} on FunctionException catch (error) {
  final message = switch (error) {
    FunctionsFetchException() => 'Network failure',
    FunctionsRelayException() => 'Relay error',
    FunctionsApiException()   => 'Function returned ${error.statusCode}',
  };
}

Breaking Changes

sealed implies abstract, which means:

  • External packages can no longer directly instantiate a bare FunctionException (e.g. in tests/mocks) or subclass/implement it.
  • Consumers should instantiate/match on one of the concrete subtypes instead (FunctionsFetchException, FunctionsApiException, FunctionsRelayException).

Documented in MIGRATION.md.

Verification

  • melos analyze: 0 issues across all 20 packages
  • melos format: 0 files changed
  • Unit tests: functions_client (51 tests) and supabase tests all pass

Closes #1550

@YadneshTeli
YadneshTeli requested a review from a team as a code owner August 14, 2026 20:07
@coderabbitai

coderabbitai Bot commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@spydon, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 29 minutes

Limit details: You’ve used all 4 included reviews currently available under your plan.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

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 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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: cfba61c4-bc31-426c-ac27-d376b4b19779

📥 Commits

Reviewing files that changed from the base of the PR and between 59e013b and 805021a.

📒 Files selected for processing (3)
  • MIGRATION.md
  • packages/supabase_functions/lib/src/types.dart
  • packages/supabase_functions/test/functions_dart_test.dart

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: c6941d3e-0160-44b4-aa87-dc4e5d0c75c3

📥 Commits

Reviewing files that changed from the base of the PR and between a0be827 and 59e013b.

📒 Files selected for processing (3)
  • MIGRATION.md
  • packages/functions_client/lib/src/types.dart
  • packages/functions_client/test/functions_dart_test.dart

📝 Walkthrough

Walkthrough

FunctionException is now a sealed class with three documented failure subtypes. Migration guidance explains the breaking changes and exhaustive pattern matching. Tests verify matching for fetch, relay, and API exceptions.

Changes

FunctionException sealing

Layer / File(s) Summary
Sealed exception contract and migration guidance
packages/functions_client/lib/src/types.dart, packages/functions_client/test/functions_dart_test.dart, MIGRATION.md
FunctionException is sealed. Documentation identifies FunctionsFetchException, FunctionsRelayException, and FunctionsApiException. Migration guidance describes exhaustive matching and restrictions on external construction or extension. Tests cover all three subtypes.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 59e01

This PR makes FunctionException sealed and documents the resulting breaking change while preserving the listed concrete failure types; no actionable merge-blocking risk remains after normal checks and review.

Possibly related PRs

Suggested labels: v3

Suggested reviewers: spydon

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR makes FunctionException sealed, but it documents and tests FunctionsApiException instead of the linked issue's required FunctionsHttpException subtype. Align the implementation, documentation, and tests with issue #1550, or update the linked issue if FunctionsApiException is the intended replacement for FunctionsHttpException.
✅ Passed checks (4 passed)
Check name Status Explanation
Out of Scope Changes check ✅ Passed The migration documentation and exhaustive pattern-matching test directly support the sealed-class change and remain within the linked issue scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the primary breaking change: making FunctionException a sealed class.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@spydon
spydon force-pushed the feat/sealed-function-exception branch from 59e013b to b6560ce Compare August 17, 2026 10:12
@spydon
spydon force-pushed the feat/sealed-function-exception branch from b6560ce to 805021a Compare August 17, 2026 10:17
@spydon
spydon enabled auto-merge (squash) August 17, 2026 10:19
@spydon
spydon merged commit cb128aa into supabase:main Aug 17, 2026
33 checks passed
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.

Make FunctionException a sealed class for v3

2 participants