Skip to content

Fix dead docs URLs in help text and superfluous WriteHeader in diagnostic handlers - #1705

Open
ZayanKhan-12 wants to merge 6 commits into
cloudflare:masterfrom
ZayanKhan-12:fix/dead-doc-links-and-diag-write-header
Open

Fix dead docs URLs in help text and superfluous WriteHeader in diagnostic handlers#1705
ZayanKhan-12 wants to merge 6 commits into
cloudflare:masterfrom
ZayanKhan-12:fix/dead-doc-links-and-diag-write-header

Conversation

@ZayanKhan-12

Copy link
Copy Markdown

What this fixes

Six commits, each independently test/lint-clean:

  1. cmd/cloudflared: fix dead license URL in --help copyright noticehttps://developers.cloudflare.com/cloudflare-one/connections/connect-apps/license returns 404 with no redirect (the docs-site reorganizations moved connect-apps content, but no license page exists at any successor path). Now points at the repo's own LICENSE, which can't rot with docs moves.
  2. cmd/cloudflared/tunnel: fix dead ingress docs URL in legacy flag help — every legacy origin flag's help text (via legacyTunnelFlag) linked .../connect-apps/configuration/configuration-file/ingress, also a hard 404. Replaced with the current canonical page (verified 200): https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/do-more-with-tunnels/local-management/configuration-file/. Same class as the previously merged Fix broken links in cmd/cloudflared/*.go related to running tunnel as a service #1219.
  3. diagnostic: do not call WriteHeader after the response body is written — the three diagnostic handlers encoded JSON straight to the ResponseWriter and, on error, then called WriteHeader(500). When Encode fails at the write stage the response has already begun, so the call is superfluous (net/http logs a warning) and can't change the status. Now marshals first (clean 500 before any bytes on serialization failure) and reuses the package's existing — previously unused — writeResponse helper for the write path.
  4. diagnostic: add regression test for WriteHeader-after-body — drives each handler with a ResponseWriter whose Write fails and records ordering; fails for all three handlers without commit 3.
  5. cmd/cloudflared: satisfy errcheck and prealloc in main.go — pre-existing findings surfaced by the whole-file lint policy on touched files (per AGENTS.md).
  6. diagnostic: drop unused test constants — same policy; systemInformationKey/errorKey are referenced nowhere.

Verification (macOS arm64, Go 1.26.5)

  • URL status codes checked with curl: old license URL 404, old ingress URL 404, replacement 200
  • make cloudflared ✅ · make test (go vet + go test -race ./...) ✅ 0 failures · make lint ✅ 0 issues · make fmt-check
  • Regression test proven: fails on all three handlers against the pre-fix code, passes after
  • component-tests need a live Cloudflare account/tunnel and were not run

Prepared with AI assistance (Claude) following AGENTS.md; every change was mechanically verified as described above.

zk-khan and others added 6 commits July 26, 2026 18:37
https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/license
returns 404 with no redirect after the docs-site reorganizations. Point at
the repository's own LICENSE file, which cannot rot with docs moves.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The configuration-file/ingress page under connect-apps returns 404 with
no redirect; every legacy origin flag's help text linked it. Use the
current canonical configuration-file page (verified 200).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The three diagnostic handlers encoded JSON straight to the
ResponseWriter and, on error, then called WriteHeader(500). When
Encode fails at the write stage the response has already begun, so the
WriteHeader call is superfluous (net/http logs a warning) and cannot
change the status. Marshal first, return a clean 500 on serialization
failure before any bytes hit the wire, and reuse the package's
writeResponse helper (previously unused) for the write path.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Each handler is driven with a ResponseWriter whose Write fails and
which records whether WriteHeader is called after body bytes were
written. Fails for all three handlers without the previous commit.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Pre-existing findings surfaced by the whole-file lint policy on touched
files: explicitly discard the os.Setenv error (matching the adjacent
maxprocs.Set() style) and annotate the one-time command-registration
literal rather than restructuring it for prealloc.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
systemInformationKey and errorKey are referenced nowhere in the module;
flagged by the unused linter on the touched file.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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