Skip to content

TW-5093: fix webhooks server --json output with cloudflare tunnel#95

Merged
qasim-nylas merged 1 commit into
mainfrom
TW-5093/fix-webhooks-json-cloudflare
May 19, 2026
Merged

TW-5093: fix webhooks server --json output with cloudflare tunnel#95
qasim-nylas merged 1 commit into
mainfrom
TW-5093/fix-webhooks-json-cloudflare

Conversation

@qasim-nylas
Copy link
Copy Markdown
Collaborator

Summary

  • Fix broken JSON output: --json flag was mixing human-readable banner/server-info/shutdown text with JSON events on stdout, breaking any consumer piping to jq or a JSON parser. Now --json produces pure JSONL with structured lifecycle events (server.started, server.stopped).
  • Add interactive secret prompt: --tunnel cloudflared without --secret gave a hard error even on interactive terminals. Now prompts for the secret (using stderr in --json mode to keep stdout clean), matching the preflight UX.

Related docs

Test plan

  • nylas webhooks server --json --tunnel cloudflared --allow-unsigned produces clean JSONL (startup → events → shutdown)
  • nylas webhooks server --no-tunnel still shows full banner/server-info in non-JSON mode
  • nylas webhooks server --json --tunnel cloudflared prompts for secret interactively (stderr)
  • Non-interactive --json --tunnel without --secret still returns hard error with guidance
  • All 55 webhook unit tests pass
  • go build, go vet, go test clean

--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.
@qasim-nylas qasim-nylas requested a review from AaronDDM May 19, 2026 16:51
Copy link
Copy Markdown
Collaborator

@AaronDDM AaronDDM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@qasim-nylas qasim-nylas merged commit ceb7c74 into main May 19, 2026
7 checks passed
@qasim-nylas qasim-nylas deleted the TW-5093/fix-webhooks-json-cloudflare branch May 19, 2026 16:57
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