Skip to content

Revert ForceRelay default to false now that P2P issues are fixed#152

Open
MichaelUray wants to merge 1 commit intonetbirdio:mainfrom
MichaelUray:fix/force-relay-default-false
Open

Revert ForceRelay default to false now that P2P issues are fixed#152
MichaelUray wants to merge 1 commit intonetbirdio:mainfrom
MichaelUray:fix/force-relay-default-false

Conversation

@MichaelUray
Copy link
Copy Markdown

@MichaelUray MichaelUray commented Apr 6, 2026

Summary

The default for isConnectionForceRelayed was set to true in #108 as a workaround for P2P stability issues on Android. The underlying ICE issues have since been fixed (netbirdio/netbird: guard loop fix, candidate buffering, anet for Android interface discovery), so P2P connections work reliably and should be enabled by default.

This is a one-line change: getBoolean(keyForceRelayConnection, true)getBoolean(keyForceRelayConnection, false).

Checklist

  • Bug fix (reverts workaround now that root cause is fixed)
  • Documentation not needed

By submitting this pull request, I confirm that I have read and agree to the terms of the Contributor License Agreement.

Summary by CodeRabbit

  • Bug Fixes

    • Changed the default connection relay preference from enabled to disabled when not previously configured.
  • Chores

    • Updated underlying dependencies.

The default was set to true in netbirdio#108 as a workaround for P2P stability
issues on Android. Now that the underlying ICE issues are fixed
(netbirdio/netbird: guard loop, candidate buffering, anet for Android),
P2P connections work reliably and should be enabled by default.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 6, 2026

📝 Walkthrough

Walkthrough

This pull request updates the netbird submodule reference to a newer commit and changes the default return value of Preferences.isConnectionForceRelayed() from true to false when the preference key is absent.

Changes

Cohort / File(s) Summary
Submodule Update
.gitmodules
Updated netbird submodule commit reference from 7bbe71c3 to d0aa79ee.
Preference Default Value
tool/src/main/java/io/netbird/client/tool/Preferences.java
Changed default return value of isConnectionForceRelayed() from true to false when the key is absent from SharedPreferences.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A submodule hops to newer ground,
While preferences now safely default down,
From true to false, a gentle flip,
These simple changes pass through quick! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 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 summarizes the main change: reverting the ForceRelay default from true to false due to underlying P2P issues being fixed, which aligns with the actual code changes in the PR.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@netbird`:
- Line 1: The PR changes the default for keyForceRelayConnection in
Preferences.java from true to false but that file wasn't included for review;
open Preferences.java and verify the change to
getBoolean(keyForceRelayConnection, false) is intentional and consistent with
the rest of the codebase, then update any related logic or documentation that
assumes the old default (search for keyForceRelayConnection, getBoolean, and any
code paths handling forced relay behavior) to align behavior and tests with the
new default, and add or adjust unit/integration tests that assert the previous
default to reflect the new false default.

In `@tool/src/main/java/io/netbird/client/tool/Preferences.java`:
- Line 30: The test
PreferencesInstrumentedTest.shouldReturnTrueWhenConnectionForceRelayedIsNotSet
must be updated to reflect the new default in
Preferences.isConnectionForceRelayed(): change the assertion that currently
calls assertTrue(...) to
Assert.assertFalse(preferences.isConnectionForceRelayed()); so the test verifies
the new default false value returned by
Preferences.getBoolean(keyForceRelayConnection, false).
- Line 30: The change to Preferences.isConnectionForceRelayed() returns false by
default which breaks the test
shouldReturnTrueWhenConnectionForceRelayedIsNotSet; revert the default to true
or update the method to return sharedPref.getBoolean(keyForceRelayConnection,
true) so that isConnectionForceRelayed() yields true when the preference is
unset (refer to the method isConnectionForceRelayed and the key
keyForceRelayConnection).
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: adc3d29a-5ebe-4800-bd49-f60d8c1080f6

📥 Commits

Reviewing files that changed from the base of the PR and between debe003 and ef5f776.

📒 Files selected for processing (2)
  • netbird
  • tool/src/main/java/io/netbird/client/tool/Preferences.java

@@ -1 +1 @@
Subproject commit 7bbe71c3ac4b8d95cb6e5b764dd87d6ba8c9c271
Subproject commit d0aa79eebf102ecfcccbbb73fb1bdd8547dbc26e
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.

⚠️ Potential issue | 🟠 Major

Note: Main code change (Preferences.java) not included in review files.

The PR objectives describe a critical code change in tool/src/main/java/io/netbird/client/tool/Preferences.java that changes getBoolean(keyForceRelayConnection, true) to getBoolean(keyForceRelayConnection, false). This file was not included in the files for review. Please ensure this change is also reviewed for correctness and consistency with the submodule update.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@netbird` at line 1, The PR changes the default for keyForceRelayConnection in
Preferences.java from true to false but that file wasn't included for review;
open Preferences.java and verify the change to
getBoolean(keyForceRelayConnection, false) is intentional and consistent with
the rest of the codebase, then update any related logic or documentation that
assumes the old default (search for keyForceRelayConnection, getBoolean, and any
code paths handling forced relay behavior) to align behavior and tests with the
new default, and add or adjust unit/integration tests that assert the previous
default to reflect the new false default.


public boolean isConnectionForceRelayed() {
return sharedPref.getBoolean(keyForceRelayConnection, true);
return sharedPref.getBoolean(keyForceRelayConnection, false);
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.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Verify the netbird submodule contains the P2P fixes mentioned in the PR

# Check recent commits in the netbird submodule for the referenced fixes
cd netbird 2>/dev/null && git log --oneline --grep="guard loop\|candidate buffering\|anet.*Android" -20 || echo "netbird submodule not found in current directory"

# Search for any migration logic related to this preference
cd ..
rg -n -C5 'keyForceRelayConnection|isConnectionForceRelayed' --type java --type kotlin

Repository: netbirdio/android-client

Length of output: 8356


🏁 Script executed:

# Check the entire PreferencesInstrumentedTest file to see all affected tests
cat -n tool/src/androidTest/java/io/netbird/client/tool/PreferencesInstrumentedTest.java

Repository: netbirdio/android-client

Length of output: 3265


Update test to match new default behavior.

The test shouldReturnTrueWhenConnectionForceRelayedIsNotSet (line 48-50 in PreferencesInstrumentedTest.java) will fail because it asserts assertTrue() while the new default is false. Update the assertion to Assert.assertFalse(preferences.isConnectionForceRelayed()); to match the changed default in Preferences.java line 30.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tool/src/main/java/io/netbird/client/tool/Preferences.java` at line 30, The
test
PreferencesInstrumentedTest.shouldReturnTrueWhenConnectionForceRelayedIsNotSet
must be updated to reflect the new default in
Preferences.isConnectionForceRelayed(): change the assertion that currently
calls assertTrue(...) to
Assert.assertFalse(preferences.isConnectionForceRelayed()); so the test verifies
the new default false value returned by
Preferences.getBoolean(keyForceRelayConnection, false).

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Search for tests and code that may depend on the default value of isConnectionForceRelayed

# Search for test assertions on isConnectionForceRelayed
rg -n -C3 'isConnectionForceRelayed\(\)' --glob '*Test*.java' --glob '*Test*.kt'

# Search for any other references to verify migration impact
rg -n -C3 'isConnectionForceRelayed' --type java

Repository: netbirdio/android-client

Length of output: 7657


The test shouldReturnTrueWhenConnectionForceRelayedIsNotSet will fail with this change.

The test at tool/src/androidTest/java/io/netbird/client/tool/PreferencesInstrumentedTest.java:49 asserts assertTrue(preferences.isConnectionForceRelayed()), but the new default is false. This will block the build.

Fix
 `@Test`
-    public void shouldReturnTrueWhenConnectionForceRelayedIsNotSet() {
-        Assert.assertTrue(preferences.isConnectionForceRelayed());
+    public void shouldReturnFalseWhenConnectionForceRelayedIsNotSet() {
+        Assert.assertFalse(preferences.isConnectionForceRelayed());
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tool/src/main/java/io/netbird/client/tool/Preferences.java` at line 30, The
change to Preferences.isConnectionForceRelayed() returns false by default which
breaks the test shouldReturnTrueWhenConnectionForceRelayedIsNotSet; revert the
default to true or update the method to return
sharedPref.getBoolean(keyForceRelayConnection, true) so that
isConnectionForceRelayed() yields true when the preference is unset (refer to
the method isConnectionForceRelayed and the key keyForceRelayConnection).

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