Skip to content

Replace environment, restHost and realtimeHost with endpoint - #1249

Open
ttypic wants to merge 1 commit into
integration/split-6-deprecation-methodsfrom
integration/split-7-endpoint-option
Open

ttypic wants to merge 1 commit into
integration/split-6-deprecation-methodsfrom
integration/split-7-endpoint-option

Conversation

@ttypic

@ttypic ttypic commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

2.0 adopts the REC1/REC2 host model (ADR-119): a single
ClientOptions.endpoint selects where both REST requests and the realtime
connection go, and the legacy environment, restHost and realtimeHost
options are removed outright, so old code fails to compile rather than
silently connecting to production.

  • endpoint resolves as: unset -> main.realtime.ably.net; a routing policy
    name -> [name].realtime.ably.net; nonprod:[name] ->
    [name].realtime.ably-nonprod.net; a hostname (contains '.' or '::', or
    is localhost) -> used as given. Default fallbacks follow the endpoint
    ([name].[a-e].fallback.ably-realtime[-nonprod].com) and a hostname has
    none.

  • Hosts now resolves from ClientOptions alone, so HttpCore and
    ConnectionManager share one primary domain. The restHost/environment
    conflict check, the rest.ably.io/realtime.ably.io defaults and the
    -[a-e]-fallback hosts go with the legacy options.

  • An explicit fallbackHosts always replaces the defaults (REC2a2), and a
    custom port or tlsPort no longer suppresses the default fallbacks, as
    the spec has no such rule.

  • The server and device builders swap restHost(), realtimeHost() and
    environment() for endpoint().

Summary by CodeRabbit

  • New Features

    • Added a unified endpoint setting for configuring REST and realtime connections, supporting routing-policy names, nonproduction endpoints, and explicit hostnames.
    • Endpoint-based fallback hosts are selected automatically; custom fallback hosts replace the defaults when provided.
    • IPv6 addresses are now formatted correctly in HTTP and WebSocket connection URLs.
  • Documentation

    • Added migration guidance for replacing separate host and environment settings.
    • Updated setup examples and test instructions to use endpoint configuration, including the sandbox endpoint.
  • Compatibility

    • Builder APIs no longer support separate REST host, realtime host, or environment settings.

@coderabbitai

coderabbitai Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 10de84ce-933c-4eb8-b0d1-6929622dd20a

📥 Commits

Reviewing files that changed from the base of the PR and between 3298eb3 and f0f58a9.


📒 Files selected for processing (6)
  • lib/src/main/java/io/ably/pubsub/http/HttpUtils.java
  • lib/src/main/java/io/ably/pubsub/transport/WebSocketTransport.java
  • lib/src/test/java/io/ably/pubsub/http/HttpUtilsTest.java
  • uts/README.md
  • uts/src/main/kotlin/io/ably/pubsub/uts/infra/integration/SandboxApp.kt
  • uts/src/main/kotlin/io/ably/pubsub/uts/infra/integration/proxy/ProxySession.kt

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.



Walkthrough

Client configuration now uses one endpoint for REST and realtime traffic. Endpoint values determine primary and fallback hosts. Builders, tests, examples, and sandbox integrations use endpoint configuration. URL construction brackets IPv6 hosts.

Changes

Endpoint Routing

Layer / File(s) Summary
Endpoint contract and host resolution
lib/src/main/java/io/ably/pubsub/types/ClientOptions.java, lib/src/main/java/io/ably/pubsub/transport/*, lib/src/main/java/io/ably/pubsub/http/HttpCore.java, lib/src/main/java/io/ably/pubsub/transport/ConnectionManager.java, lib/src/test/java/io/ably/pubsub/transport/*Test.java, lib/src/test/java/io/ably/pubsub/test/http/HttpInitTest.java, lib/src/test/java/io/ably/pubsub/test/http/HttpTest.java, lib/src/test/java/io/ably/pubsub/test/realtime/ConnectionManagerTest.java, UPGRADING.md
ClientOptions now uses endpoint. Defaults resolves primary and fallback hosts for routing-policy endpoints and returns hostname endpoints unchanged, with no default fallbacks. Hosts uses these rules unless explicit fallbacks are set. Tests cover these cases, and the upgrade guide documents the endpoint migration.
Builder and client configuration updates
device/src/commonMain/kotlin/io/ably/pubsub/device/PubSubDevice.kt, server/src/main/java/io/ably/pubsub/server/PubSubServer.java, lib/src/test/java/io/ably/pubsub/test/common/Setup.java, lib/src/test/java/io/ably/pubsub/test/{http,realtime}/*Test.java, core-android/src/*, examples/src/main/kotlin/com/ably/example/*, pubsub-adapter/src/test/kotlin/com/ably/Utils.kt, server/src/test/java/io/ably/pubsub/server/PubSubServerTest.java, CONTRIBUTING.md
Builders replace host setters with endpoint and remove environment setters. Test setup reads ABLY_ENDPOINT and defaults to nonprod:sandbox. Related tests, examples, and contributor instructions use endpoint values.
Sandbox and proxy endpoint wiring
uts/src/main/kotlin/io/ably/pubsub/uts/infra/integration/*, uts/src/test/kotlin/io/ably/pubsub/uts/integration/standard/*, uts/README.md, .claude/skills/uts-to-kotlin/SKILL.md, .claude/skills/uts-to-kotlin/references/objects-mapping.md, lib/src/test/kotlin/io/ably/pubsub/uts/integration/standard/realtime/*, liveobjects/src/test/kotlin/io/ably/pubsub/liveobjects/*
SandboxApp adds sandboxEndpoint with the value nonprod:sandbox. Direct sandbox clients use that endpoint. Proxy setup uses the proxy hostname as its endpoint, and sandboxHost remains the documented upstream hostname.
IPv6 URL host formatting
lib/src/main/java/io/ably/pubsub/http/HttpUtils.java, lib/src/main/java/io/ably/pubsub/transport/WebSocketTransport.java, lib/src/test/java/io/ably/pubsub/http/HttpUtilsTest.java
HttpUtils brackets unbracketed IPv6 hosts when building URLs. WebSocket URI construction uses the same formatter. Tests check IPv6 formatting and unchanged host inputs.

Priority: ➖ Normal

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant ClientOptions
  participant HttpCore
  participant ConnectionManager
  participant Hosts
  participant Defaults
  ClientOptions->>HttpCore: Provide endpoint options
  HttpCore->>Hosts: Construct Hosts(options)
  ClientOptions->>ConnectionManager: Provide endpoint options
  ConnectionManager->>Hosts: Construct Hosts(options)
  Hosts->>Defaults: Resolve primary domain and fallback hosts
  Defaults-->>Hosts: Return endpoint-derived hosts
  Hosts-->>HttpCore: Return resolved host configuration
  Hosts-->>ConnectionManager: Return resolved host configuration
Loading

Merge Risk: ⚪ Minimal · up to f0f58

No merge-blocking issue is identified; the PR is ready for normal checks.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 76.23% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 122 functions across 45 files. (1 skipped… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: replacing the legacy environment, restHost, and realtimeHost options with endpoint.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.

Full details: Docstring Coverage

Explanation

Docstring coverage is 76.23% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 122 functions across 45 files. (1 skipped: 1 unsupported.)



  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR


  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

A rabbit sets one endpoint in place,
For REST and realtime to share their space.
Sandbox paths take a named route,
Proxy hosts pass upstream out.
IPv6 gains brackets snug,
Then hops along with a URL hug.

Comment @coderabbitai help to get the list of available commands.

@ttypic
ttypic changed the base branch from main to integration/split-6-deprecation-methods October 8, 2026 19:18
@ttypic
ttypic requested a review from sacOO7 October 8, 2026 19:18
@ttypic ttypic changed the title integration/split-7-endpoint-option Replace environment, restHost and realtimeHost with endpoint Oct 8, 2026
@sacOO7
sacOO7 requested a lite review from Copilot October 9, 2026 09:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Accepted IPv6 endpoints produce malformed transport URLs and cannot connect.

1 open finding
What changed in this PR

This PR replaces separate host and environment settings with one endpoint for REST and realtime clients, aligning the SDK with the new host-routing model.

Changes:

  • Resolves primary and fallback hosts from endpoint.
  • Migrates builders, tests, examples, and integration helpers to the new option.
  • Adds upgrade and test-setup guidance.
File Description
uts/​src/​test/​kotlin/​io/​ably/​pubsub/​uts/​integration/​standard/​IntegrationInfraSmokeTest.kt Uses the sandbox endpoint.
uts/​src/​main/​kotlin/​io/​ably/​pubsub/​uts/​infra/​integration/​SandboxApp.kt Defines the sandbox endpoint.
uts/​src/​main/​kotlin/​io/​ably/​pubsub/​uts/​infra/​integration/​proxy/​ProxySession.kt Routes proxy clients through endpoint.
uts/​README.md Updates integration setup guidance.
UPGRADING.md Documents endpoint migration.
server/​src/​test/​java/​io/​ably/​pubsub/​server/​PubSubServerTest.java Migrates server builder test.
server/​src/​main/​java/​io/​ably/​pubsub/​server/​PubSubServer.java Replaces legacy builder methods.
pubsub-adapter/​src/​test/​kotlin/​com/​ably/​Utils.kt Migrates local test client.
liveobjects/​src/​test/​kotlin/​io/​ably/​pubsub/​liveobjects/​uts/​proxy/​ObjectsFaultsTest.kt Migrates direct sandbox client.
liveobjects/​src/​test/​kotlin/​io/​ably/​pubsub/​liveobjects/​uts/​integration/​ObjectsSyncTest.kt Migrates sync test client.
liveobjects/​src/​test/​kotlin/​io/​ably/​pubsub/​liveobjects/​uts/​integration/​ObjectsLifecycleTest.kt Migrates lifecycle test client.
liveobjects/​src/​test/​kotlin/​io/​ably/​pubsub/​liveobjects/​uts/​integration/​Helpers.kt Migrates HTTP provisioning.
liveobjects/​src/​test/​kotlin/​io/​ably/​pubsub/​liveobjects/​integration/​setup/​Sandbox.kt Migrates sandbox setup.
lib/​src/​test/​kotlin/​io/​ably/​pubsub/​uts/​integration/​standard/​realtime/​TokenRequestTest.kt Migrates token test clients.
lib/​src/​test/​kotlin/​io/​ably/​pubsub/​uts/​integration/​standard/​realtime/​ChannelHistoryTest.kt Migrates history test client.
lib/​src/​test/​java/​io/​ably/​pubsub/​transport/​HostsTest.java Tests endpoint fallback behavior.
lib/​src/​test/​java/​io/​ably/​pubsub/​transport/​DefaultsTest.java Tests endpoint resolution.
lib/​src/​test/​java/​io/​ably/​pubsub/​test/​realtime/​RealtimeJWTTest.java Migrates JWT test options.
lib/​src/​test/​java/​io/​ably/​pubsub/​test/​realtime/​RealtimeInitTest.java Migrates initialization test.
lib/​src/​test/​java/​io/​ably/​pubsub/​test/​realtime/​RealtimeHttpHeaderTest.java Migrates WebSocket test options.
lib/​src/​test/​java/​io/​ably/​pubsub/​test/​realtime/​RealtimeConnectFailTest.java Migrates failure test endpoints.
lib/​src/​test/​java/​io/​ably/​pubsub/​test/​realtime/​ConnectionManagerTest.java Updates connection host assertions.
lib/​src/​test/​java/​io/​ably/​pubsub/​test/​http/​HttpTimeTest.java Migrates invalid-host test.
lib/​src/​test/​java/​io/​ably/​pubsub/​test/​http/​HttpTest.java Updates HTTP host tests.
lib/​src/​test/​java/​io/​ably/​pubsub/​test/​http/​HttpRequestTest.java Migrates request test endpoints.
lib/​src/​test/​java/​io/​ably/​pubsub/​test/​http/​HttpProxyTest.java Disables fallback for a proxy test.
lib/​src/​test/​java/​io/​ably/​pubsub/​test/​http/​HttpJWTTest.java Derives JWT test environment.
lib/​src/​test/​java/​io/​ably/​pubsub/​test/​http/​HttpInitTest.java Tests new HTTP host resolution.
lib/​src/​test/​java/​io/​ably/​pubsub/​test/​http/​HttpHeaderTest.java Migrates local HTTP tests.
lib/​src/​test/​java/​io/​ably/​pubsub/​test/​http/​HttpErrorTest.java Migrates local error tests.
lib/​src/​test/​java/​io/​ably/​pubsub/​test/​http/​HttpClientTest.java Migrates fallback test endpoints.
lib/​src/​test/​java/​io/​ably/​pubsub/​test/​http/​HttpAuthTest.java Migrates authentication test options.
lib/​src/​test/​java/​io/​ably/​pubsub/​test/​common/​Setup.java Sets test endpoints centrally.
lib/​src/​main/​java/​io/​ably/​pubsub/​types/​ClientOptions.java Adds endpoint; removes legacy options.
lib/​src/​main/​java/​io/​ably/​pubsub/​transport/​Hosts.java Derives hosts from client options.
lib/​src/​main/​java/​io/​ably/​pubsub/​transport/​Defaults.java Resolves endpoint domains and fallbacks.
lib/​src/​main/​java/​io/​ably/​pubsub/​transport/​ConnectionManager.java Uses shared host resolution.
lib/​src/​main/​java/​io/​ably/​pubsub/​http/​HttpCore.java Uses shared host resolution.
lib/​src/​main/​java/​io/​ably/​pubsub/​debug/​DebugOptions.java Copies the endpoint option.
examples/​src/​main/​kotlin/​com/​ably/​example/​screen/​MainScreen.kt Detects the sandbox endpoint.
examples/​src/​main/​kotlin/​com/​ably/​example/​MainActivity.kt Configures the sandbox endpoint.
device/​src/​commonMain/​kotlin/​io/​ably/​pubsub/​device/​PubSubDevice.kt Replaces legacy builder methods.
core-android/​src/​main/​java/​io/​ably/​pubsub/​push/​ActivationContext.java Updates an options TODO comment.
core-android/​src/​androidTest/​java/​io/​ably/​pubsub/​test/​android/​AndroidSuite.java Migrates Android HTTP test.
CONTRIBUTING.md Updates test configuration guidance.
.claude/​skills/​uts-to-kotlin/​SKILL.md Updates test-translation guidance.
.claude/​skills/​uts-to-kotlin/​references/​objects-mapping.md Updates sandbox mapping guidance.

🧠 Review effort: Lite


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +91 to +92
if (isHostname(endpoint)) {
return endpoint;
2.0 adopts the REC1/REC2 host model (ADR-119): a single
ClientOptions.endpoint selects where both REST requests and the realtime
connection go, and the legacy environment, restHost and realtimeHost
options are removed outright, so old code fails to compile rather than
silently connecting to production.

- endpoint resolves as: unset -> main.realtime.ably.net; a routing policy
  name -> [name].realtime.ably.net; nonprod:[name] ->
  [name].realtime.ably-nonprod.net; a hostname (contains '.' or '::', or
  is localhost) -> used as given. Default fallbacks follow the endpoint
  ([name].[a-e].fallback.ably-realtime[-nonprod].com) and a hostname has
  none.

- Hosts now resolves from ClientOptions alone, so HttpCore and
  ConnectionManager share one primary domain. The restHost/environment
  conflict check, the rest.ably.io/realtime.ably.io defaults and the
  <env>-[a-e]-fallback hosts go with the legacy options.

- An explicit fallbackHosts always replaces the defaults (REC2a2), and a
  custom port or tlsPort no longer suppresses the default fallbacks, as
  the spec has no such rule.

- The server and device builders swap restHost(), realtimeHost() and
  environment() for endpoint().

The tests move to endpoint throughout: ABLY_ENV, ABLY_REST_HOST and
ABLY_REALTIME_HOST become ABLY_ENDPOINT (default nonprod:sandbox), UTS
and LiveObjects sandbox clients use the new
SandboxApp.sandboxEndpoint, and mock/proxy clients use a localhost
endpoint. Tests of the legacy host derivation and option conflicts are
replaced by DefaultsTest/HostsTest cases for each endpoint form, custom
fallbackHosts, and ports no longer disabling fallbacks. UPGRADING.md
gains the migration table and the firewall allowlist note.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

This branch was successfully deployed

2 active deployments
staging/pull/1249/javadoc — f0f58a95 Deployed Oct 9, 2026 by github-actions[bot]
staging/pull/1249/features — f0f58a95 Deployed Oct 9, 2026 by github-actions[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants