feat(hub): poll remote API for beta/dev servers #96
No reviewers
Labels
No labels
blocked
bug
dependencies
documentation
duplicate
enhancement
github_actions
go
good first issue
help wanted
in-progress
invalid
question
ready-to-fix
source:discord
source:sentry
source:server-logs
triage-needed
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
pokebedrock/pokebedrock-hub!96
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "dev-servers"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Dynamic dev-* registry + gated Beta Navigator item for Supporters/Mod+, shared CanAccessBeta helper.
Summary by CodeRabbit
📝 Walkthrough
Walkthrough
Adds configurable polling for remote dev servers, synchronizes them with the local registry, exposes beta servers through a gated navigator, excludes them from the standard navigator, and refreshes lobby kits after rank synchronization.
Changes
Dev server and beta access flow
config.example.toml,pokebedrock/config.go,pokebedrock/devserver/*pokebedrock/pokebedrock.gopokebedrock/rank/*,pokebedrock/handler/player.go,pokebedrock/kit/lobby.go,pokebedrock/form/*pokebedrock/session/ranks.goEstimated code review effort: 4 (Complex) | ~45 minutes
Sequence Diagram(s)
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches
📝 Generate docstrings
🧪 Generate unit tests (beta)
dev-serversThanks 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 helpto get the list of available commands.Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID:
c35154a3-aa48-4576-b63b-31f44987b24f📥 Commits
Reviewing files that changed from the base of the PR and between
fddd8bfcc2and193c36337b.📒 Files selected for processing (14)
config.example.tomlpokebedrock/config.gopokebedrock/devserver/diff_test.gopokebedrock/devserver/service.gopokebedrock/devserver/types.gopokebedrock/form/beta_navigator.gopokebedrock/form/server_confirm.gopokebedrock/form/server_navigator.gopokebedrock/handler/player.gopokebedrock/kit/lobby.gopokebedrock/pokebedrock.gopokebedrock/rank/access.gopokebedrock/rank/access_test.gopokebedrock/session/ranks.go@ -0,0 +95,4 @@select {case <-s.done:case <-time.After(3 * time.Second):}🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: smell-of-curry/pokebedrock-hub
Length of output: 1086
🏁 Script executed:
Repository: smell-of-curry/pokebedrock-hub
Length of output: 23721
Cancel an in-flight poll before shutdown continues.
Stopgives the poller a 3s shutdown window, but a longfetchrequest can run for 5s because its cancel only wrapscontext.Background(). If that call is pending when the ticker fires afterStop, it returns after the 3s timeout and then registers/unregisters servers afterPokeBedrock.Close()has already called the stop and proceeds to close the server. Store a service-level cancel context, cancel it fromStop, and wait fordonefrom the cancelled request.🤖 Prompt for AI Agents
@ -0,0 +83,4 @@Name: DisplayName(s),Identifier: id,Address: net.JoinHostPort(host, strconv.Itoa(s.Port)),BetaLock: true,🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: smell-of-curry/pokebedrock-hub
Length of output: 2670
🏁 Script executed:
Repository: smell-of-curry/pokebedrock-hub
Length of output: 259
🏁 Script executed:
Repository: smell-of-curry/pokebedrock-hub
Length of output: 9759
🌐 Web query:
Go net JoinHostPort host port 0 65536 formatting behavior💡 Result:
The Go net.JoinHostPort(host, port) function does not perform validation on the host or port arguments [1][2]. It is a string manipulation utility that combines a host and a port into the "host:port" format, or "[host]:port" if the host contains colons (typically identifying it as an IPv6 address) [1][2]. Regarding your query about the 0 to 65536 range: 1. No Validation: JoinHostPort does not check if the port is a valid numeric port, nor does it enforce the 0–65536 range [1][2]. It accepts any string for the port argument and simply appends it to the host separated by a colon [1][2]. 2. Formatting Behavior: - If the host contains a colon, the function wraps the host in square brackets: [host]:port [1][2]. - If the host does not contain a colon, it returns the host directly followed by a colon and the port: host:port [1][2]. - If the port argument is empty, the function still appends the colon, resulting in "host:" or "[host]:" [3][4]. Because the function treats the port as a raw string, passing "65536" or "0" will result in those literal strings being placed after the colon without error [1][2]. Any validation of the port range must be performed by the caller before calling JoinHostPort [1].
Citations:
github.com/golang/go@e8a02230f2/src/lib/net/net.goReject invalid remote server ports before registering them.
net.JoinHostPortformats ports as strings without range validation, so a malformedportfrom the/dev-serversresponse can be registered as unreachable. ValidatePortas1..65535sopollOncekeeps the current registry instead of applying an invalid update.Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents
@ -0,0 +56,4 @@return}p.SendForm(NewServerConfirm(server))🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
Enforce beta eligibility at use time.
Eligibility is currently only checked when constructing the lobby kit. A previously issued form or stale compass can still reach confirmation;
ServerConfirmonly rejects servers withBetaLock, while this navigator lists all dev identifiers.pokebedrock/form/beta_navigator.go#L49-L59: recheck the submitter’s current ranks before sendingNewServerConfirm.pokebedrock/handler/player.go#L99-L100: reject"beta-navigator"actions when!h.CanAccessBeta().pokebedrock/session/ranks.go#L143-L149: also refresh the guarded lobby kit after resetting ranks toUnLinkedon fetch failure, removing stale gated items.📍 Affects 3 files
pokebedrock/form/beta_navigator.go#L49-L59(this comment)pokebedrock/handler/player.go#L99-L100pokebedrock/session/ranks.go#L143-L149🤖 Prompt for AI Agents
193c36337btocc4da48c03Addressed the 3 CodeRabbit findings in
cc4da48(rebased ontomain):context.WithCancel;Stopcancels in-flight fetch; skip registry mutate if cancelled1..65535(test added)UnLinked