Skip to content

Follow up changes for the Go ConnStatus enum type#147

Merged
pappz merged 3 commits intomainfrom
refactor/android-connstatus-enum
Mar 31, 2026
Merged

Follow up changes for the Go ConnStatus enum type#147
pappz merged 3 commits intomainfrom
refactor/android-connstatus-enum

Conversation

@pappz
Copy link
Copy Markdown
Collaborator

@pappz pappz commented Mar 30, 2026

Follow up changes for the Go ConnStatus enum type

netbirdio/netbird#5644

Summary by CodeRabbit

  • Refactor

    • Improved how peer connection statuses are interpreted and counted, making connectivity reporting more accurate and resilient to missing or unexpected status values.
  • Chores

    • Updated netbird module reference to a newer commit.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 30, 2026

Warning

Rate limit exceeded

@pappz has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 20 minutes and 35 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 20 minutes and 35 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1e4b645a-33b4-425a-bc81-9aaf36482dbd

📥 Commits

Reviewing files that changed from the base of the PR and between 3dcea20 and 5c6facd.

📒 Files selected for processing (2)
  • app/src/main/java/io/netbird/client/ui/home/PeersFragmentViewModel.java
  • app/src/main/java/io/netbird/client/ui/home/Status.java
📝 Walkthrough

Walkthrough

Replaces string-based connection-status handling with a numeric-based conversion by adding Status.fromLong(long) and using it across fragments and viewmodels; updates netbird submodule pointer.

Changes

Cohort / File(s) Summary
Status Enum Enhancement
app/src/main/java/io/netbird/client/ui/home/Status.java
Added fromLong(long status) mapping Android numeric ConnStatus constants to Status enum; throws IllegalArgumentException for unknown values.
ViewModels
app/src/main/java/io/netbird/client/ui/home/NetworksFragmentViewModel.java, app/src/main/java/io/netbird/client/ui/home/PeersFragmentViewModel.java
Switched conversion from string-based fromString to numeric fromLong; PeersFragmentViewModel now attempts numeric parse and maps invalid values to Status.IDLE instead of skipping peers due to null/invalid strings.
Fragments
app/src/main/java/io/netbird/client/ui/home/HomeFragment.java
Replaced string equalsIgnoreCase checks with Status.fromLong(...) + enum comparison (== Status.CONNECTED).
Submodule
netbird
Updated submodule pointer to a newer commit hash.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 I nibbled strings and found them thin,

Now numbers guide the hops within,
Enums stand firm, no casing fray,
Connections counted—clear as day,
A little hop for code today.

🚥 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 'Follow up changes for the Go ConnStatus enum type' accurately reflects the main objective of the PR, which updates connection status handling across multiple Java files to use a new Status.fromLong() factory method aligned with Go's ConnStatus enum type.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/android-connstatus-enum

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 `@app/src/main/java/io/netbird/client/ui/home/PeersFragmentViewModel.java`:
- Line 57: Wrap the call to Status.fromLong(peerInfo.getConnStatus()) in a
try-catch inside PeersFragmentViewModel's onPeersChanged handler to prevent an
IllegalArgumentException from crashing the app when an unknown code is returned;
on exception, log the error (using the existing logger or Android Log) and
assign a safe fallback status (e.g., Status.UNKNOWN or a sane default used
elsewhere) before continuing to update peers so the UI remains stable.

In `@app/src/main/java/io/netbird/client/ui/home/Status.java`:
- Around line 27-36: The fromLong method currently throws on unmapped values
causing runtime crashes; modify Status.fromLong to return a forward-compatible
fallback (e.g., UNKNOWN) instead of throwing for any value not matching
Android.ConnStatusIdle/Connecting/Connected, and ensure the Status enum declares
an UNKNOWN constant; update any related assumptions in callers
(PeersFragmentViewModel, HomeFragment, NetworksFragmentViewModel) to handle
UNKNOWN as a valid state rather than expecting an exception.

In `@netbird`:
- Line 1: The netbird submodule commit hash
7bbe71c3ac4b8d95cb6e5b764dd87d6ba8c9c271 cannot be found; verify and update the
submodule reference to a valid upstream commit or branch that contains the
ConnStatus enum change (ConnStatus enum conversion from string to integer
constants). Fix by fetching the correct commit from the upstream netbird repo
(or use the PR branch that implements the ConnStatus change), update the
submodule pointer (git submodule set-branch / git submodule update --init
--recursive or update .gitmodules commit SHA), commit the updated submodule
reference in this repo, and rerun the build to confirm the ConnStatus enum is
present. Ensure the commit you reference actually contains the ConnStatus symbol
change before pushing the submodule update.
🪄 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: 64a34c91-19a1-429a-9fc3-aa5fc5ddd49b

📥 Commits

Reviewing files that changed from the base of the PR and between f7e1c65 and b5b0da9.

📒 Files selected for processing (5)
  • app/src/main/java/io/netbird/client/ui/home/HomeFragment.java
  • app/src/main/java/io/netbird/client/ui/home/NetworksFragmentViewModel.java
  • app/src/main/java/io/netbird/client/ui/home/PeersFragmentViewModel.java
  • app/src/main/java/io/netbird/client/ui/home/Status.java
  • netbird

@@ -1 +1 @@
Subproject commit 67211010f7240d53734abd922777c32fccb02754
Subproject commit 7bbe71c3ac4b8d95cb6e5b764dd87d6ba8c9c271
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 commit exists and get its details

# Navigate to the netbird submodule directory
cd netbird || exit 1

# Verify the new commit exists
if git cat-file -e 7bbe71c3ac4b8d95cb6e5b764dd87d6ba8c9c271^{commit} 2>/dev/null; then
  echo "✓ Commit exists"
  
  # Get commit details
  echo ""
  echo "=== Commit Details ==="
  git log -1 --format="%H%n%an <%ae>%n%ad%n%s%n%n%b" 7bbe71c3ac4b8d95cb6e5b764dd87d6ba8c9c271
  
  # Get list of changed files
  echo ""
  echo "=== Changed Files ==="
  git diff --name-status 67211010f7240d53734abd922777c32fccb02754..7bbe71c3ac4b8d95cb6e5b764dd87d6ba8c9c271
  
  # Search for ConnStatus related changes
  echo ""
  echo "=== ConnStatus Related Changes ==="
  git log --oneline 67211010f7240d53734abd922777c32fccb02754..7bbe71c3ac4b8d95cb6e5b764dd87d6ba8c9c271 | grep -i "connstatus\|status" || echo "No ConnStatus-related commits found in log"
else
  echo "✗ Commit 7bbe71c3ac4b8d95cb6e5b764dd87d6ba8c9c271 does not exist"
  exit 1
fi

Repository: netbirdio/android-client

Length of output: 132


🌐 Web query:

What changes were made in netbird PR #5644 related to ConnStatus enum type?

💡 Result:

In NetBird PR #5644 (“Refactor Android PeerInfo to use proper ConnStatus enum type”), the Android-facing API was changed to stop exposing connection status as a string and instead expose an enum-backed integer:

  • PeerInfo.ConnStatus changed from string (with a TODO to “replace to enum”) to an int in client/android/peer_notifier.go. New exported gomobile-friendly constants were added:
    • ConnStatusIdle = int(peer.StatusIdle)
    • ConnStatusConnecting = int(peer.StatusConnecting)
    • ConnStatusConnected = int(peer.StatusConnected) (github.com)
  • Client.PeersList() was updated to assign ConnStatus via direct enum-to-int conversion (int(p.ConnStatus)) instead of using the string form (p.ConnStatus.String()). (github.com)
  • Overall intent: simplify Android PeerInfo ConnStatus handling by mapping directly to the existing internal peer.ConnStatus/status enum values using integer constants (better for gomobile/Java/Kotlin bindings). (github.com)

Citations:


Cannot verify the submodule commit hash exists.

The commit 7bbe71c3ac4b8d95cb6e5b764dd87d6ba8c9c271 could not be found in the netbird submodule. Verify that the commit hash is correct and that it exists in the upstream netbird repository. While the referenced upstream PR #5644 is confirmed to contain the expected ConnStatus enum type changes (converting from string to integer constants), the actual submodule update itself cannot be validated without a valid commit hash.

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

In `@netbird` at line 1, The netbird submodule commit hash
7bbe71c3ac4b8d95cb6e5b764dd87d6ba8c9c271 cannot be found; verify and update the
submodule reference to a valid upstream commit or branch that contains the
ConnStatus enum change (ConnStatus enum conversion from string to integer
constants). Fix by fetching the correct commit from the upstream netbird repo
(or use the PR branch that implements the ConnStatus change), update the
submodule pointer (git submodule set-branch / git submodule update --init
--recursive or update .gitmodules commit SHA), commit the updated submodule
reference in this repo, and rerun the build to confirm the ConnStatus enum is
present. Ensure the commit you reference actually contains the ConnStatus symbol
change before pushing the submodule update.

lixmal
lixmal previously approved these changes Mar 30, 2026
…odel.java

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@pappz pappz requested a review from lixmal March 30, 2026 16:39
@pappz pappz merged commit debe003 into main Mar 31, 2026
7 checks passed
@pappz pappz deleted the refactor/android-connstatus-enum branch March 31, 2026 08:34
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.

2 participants