fix(main): sanitize remoteConfigURL to prevent 400 Bad Request on bandwidth reports (#82) - #106
Open
Adityakk9031 wants to merge 1 commit into
Open
fix(main): sanitize remoteConfigURL to prevent 400 Bad Request on bandwidth reports (#82)#106Adityakk9031 wants to merge 1 commit into
remoteConfigURL to prevent 400 Bad Request on bandwidth reports (#82)#106Adityakk9031 wants to merge 1 commit into
Conversation
Adityakk9031
requested review from
miloschwartz and
oschwartz10612
as code owners
July 21, 2026 12:46
… reports (fosrl#82) When REMOTE_CONFIG was provided with a trailing slash (e.g. .../gerbil/get-config/ or .../gerbil/), the old TrimSuffix logic failed to strip /gerbil/get-config due to the trailing slash, resulting in invalid endpoint URLs like http://pangolin:3001/api/v1/gerbil/get-config/gerbil/receive-bandwidth. This caused Express/Traefik to return 400 Bad Request every 10 seconds. Fix: Robustly strip trailing slashes before and after removing legacy subpaths (/gerbil/get-config, /gerbil/receive-bandwidth, /gerbil). Fixes fosrl#82
Adityakk9031
force-pushed
the
fix/issue-82
branch
from
July 21, 2026 12:48
02fbab2 to
f17612c
Compare
Author
|
@oschwartz10612 and @miloschwartz have a look |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #82.
After updating to Gerbil v1.4, bandwidth reporting failed every 10 seconds with:
Root Cause
Gerbil v1.4 changed bandwidth reporting to construct the reporting endpoint dynamically from
remoteConfigURL:The existing sanitization logic in
main.go:failed when
REMOTE_CONFIGended with a trailing slash, for example:In this case:
TrimSuffix(..., "/gerbil/get-config")failed because of the trailing/.TrimSuffix(..., "/")only removed the final slash.Gerbil then constructed an invalid endpoint:
This targeted a non-existent route, causing the server to return 400 Bad Request every 10 seconds.
Fix
Updated
remoteConfigURLsanitization to remove trailing slashes before and after stripping legacy endpoint suffixes.The normalization now correctly handles all supported formats, including:
All of these normalize to:
which results in the correct bandwidth reporting endpoint:
Testing
REMOTE_CONFIGvalues with and without trailing slashes./gerbil/get-configand/gerbil/receive-bandwidthURLs.