Fix dead docs URLs in help text and superfluous WriteHeader in diagnostic handlers - #1705
Open
ZayanKhan-12 wants to merge 6 commits into
Open
Conversation
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>
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.
What this fixes
Six commits, each independently test/lint-clean:
cmd/cloudflared: fix dead license URL in --help copyright notice—https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/licensereturns 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 ownLICENSE, which can't rot with docs moves.cmd/cloudflared/tunnel: fix dead ingress docs URL in legacy flag help— every legacy origin flag's help text (vialegacyTunnelFlag) 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 incmd/cloudflared/*.gorelated to running tunnel as a service #1219.diagnostic: do not call WriteHeader after the response body is written— the three diagnostic handlers encoded JSON straight to theResponseWriterand, on error, then calledWriteHeader(500). WhenEncodefails 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 —writeResponsehelper for the write path.diagnostic: add regression test for WriteHeader-after-body— drives each handler with aResponseWriterwhoseWritefails and records ordering; fails for all three handlers without commit 3.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).diagnostic: drop unused test constants— same policy;systemInformationKey/errorKeyare referenced nowhere.Verification (macOS arm64, Go 1.26.5)
make cloudflared✅ ·make test(go vet +go test -race ./...) ✅ 0 failures ·make lint✅ 0 issues ·make fmt-check✅Prepared with AI assistance (Claude) following AGENTS.md; every change was mechanically verified as described above.