Skip to content

Conversation

grdsdev
Copy link
Contributor

@grdsdev grdsdev commented Jul 31, 2025

What kind of change does this PR introduce?

Bug fix

What is the current behavior?

Realtime client can be initialized without an apikey

What is the new behavior?

Realtime client now requires apikey to be present

Additional context

supabase/realtime-js#502

@grdsdev grdsdev requested review from mandarini, o-santi and Copilot July 31, 2025 08:12
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR makes the API key required for the Realtime client, fixing a bug where the client could be initialized without an API key. The change ensures proper authentication by enforcing API key presence during client initialization.

  • Enforced API key requirement during RealtimeClientV2 initialization with a precondition check
  • Updated method calls from deprecated subscribe() to subscribeWithError() throughout the codebase
  • Modified test configurations to include required API key headers

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
Sources/Realtime/RealtimeClientV2.swift Made apikey property non-optional and added precondition to enforce API key requirement
Sources/Realtime/RealtimeChannelV2.swift Updated channel resubscription to use subscribeWithError() method
Tests/RealtimeTests/RealtimeChannelTests.swift Updated test configuration to include required API key and modernized subscription method calls

@@ -499,7 +499,7 @@ public final class RealtimeChannelV2: Sendable, RealtimeChannelProtocol {
)
Task {
await unsubscribe()
await subscribe()
try? await subscribeWithError()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unrelated change, but it just fixes a deprecation warning

@grdsdev grdsdev merged commit 237ac9c into main Aug 5, 2025
17 checks passed
@grdsdev grdsdev deleted the guilherme/clibs-246-make-api-key-mandatory-in-supabase-swift-realtime-client branch August 5, 2025 11:31
@supabase-releaser
Copy link

🎉 This PR is included in version 2.31.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants