TW-5093: fix webhooks server --json output with cloudflare tunnel#95
Merged
Conversation
--json flag was mixing human-readable banner/server-info with JSON events on stdout, breaking JSON consumers (jq, pipes). Also, --tunnel without --secret gave a hard error even on interactive terminals instead of prompting for the secret like the preflight does. Suppress non-JSON chrome when --json is active and emit structured JSONL lifecycle events (server.started, server.stopped) so tunnel URLs remain discoverable. Add interactive secret prompt before the hard error gate, using stderr for prompts in --json mode to keep stdout clean.
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
--jsonflag was mixing human-readable banner/server-info/shutdown text with JSON events on stdout, breaking any consumer piping tojqor a JSON parser. Now--jsonproduces pure JSONL with structured lifecycle events (server.started,server.stopped).--tunnel cloudflaredwithout--secretgave a hard error even on interactive terminals. Now prompts for the secret (using stderr in--jsonmode to keep stdout clean), matching the preflight UX.Related docs
Test plan
nylas webhooks server --json --tunnel cloudflared --allow-unsignedproduces clean JSONL (startup → events → shutdown)nylas webhooks server --no-tunnelstill shows full banner/server-info in non-JSON modenylas webhooks server --json --tunnel cloudflaredprompts for secret interactively (stderr)--json --tunnelwithout--secretstill returns hard error with guidancego build,go vet,go testclean