Repository navigation
fix(webhook): require ngrok authtoken before tunnel startup (#107) - #112
Open
mangeshraut712 wants to merge 1 commit into
Open
mangeshraut712 wants to merge 1 commit into
mangeshraut712 wants to merge 1 commit into
Conversation
…form#107) When running `xurl webhook start`, entering a blank prompt when `NGROK_AUTHTOKEN` was unset previously resulted in calling `ngrok.WithAuthtokenFromEnv()` with an empty token into `ngrok.Listen`. In the ngrok client SDK, missing credentials trigger exponential-backoff reconnect attempts indefinitely, causing startup to hang silently past 60 seconds without displaying any diagnostic or error. Validate the authtoken resolution beforehand via `resolveNgrokAuthtoken` and `selectNgrokAuthtoken`. If both the prompted input and `NGROK_AUTHTOKEN` environment variable are empty or whitespace, fail immediately with an actionable error message and exit code 1. Add unit tests covering prompt preference, whitespace trimming, environment fallback, and missing-credential rejection. Signed-off-by: Mangesh Raut <mbr63@drexel.edu>
Author
|
Current head |
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
Resolves #107.
When starting the webhook server with
xurl webhook start, entering an empty line at the ngrok prompt whenNGROK_AUTHTOKENwas unset in the environment resulted inngrok.WithAuthtokenFromEnv()passing an empty token tongrok.Listen(ctx, ...).In the ngrok Go client SDK, missing or invalid credentials cause
ngrok.Connectto enter an exponential-backoff retry loop without returning an error or printing a diagnostic to the console, leaving the command hanging silently past 60 seconds without establishing a tunnel or informing the user of the missing credential.Changes
cli/webhook.go:resolveNgrokAuthtokenandselectNgrokAuthtoken.NGROK_AUTHTOKEN.Error: ngrok authtoken is required. Provide it at the prompt or set the NGROK_AUTHTOKEN environment variable) and exits with code 1 immediately, eliminating the silent hang.tunnelOptswithngrok.WithAuthtoken(token).cli/webhook_test.go:NGROK_AUTHTOKENenvironment variable when prompt is blank.resolveNgrokAuthtokenwith buffered reader inputs and environment overrides.Test Plan
go build ./...passes cleanlygo test -v -race ./cli -run Ngrokpasses all 9 test casesgo test -race ./...passes across all packagesGOOS=windows GOARCH=amd64andGOOS=linux GOARCH=arm64