Visitar URL original
fix(telemetry): keep development builds from sending usage and feedback to production by marckong · Pull Request #486 · Kong/volcano-cli · GitHub
Skip to content

fix(telemetry): keep development builds from sending usage and feedback to production - #486

Open
marckong wants to merge 3 commits into
mainfrom
marckong/vol-1615-posthog-dev-gate
Open

marckong wants to merge 3 commits into
mainfrom
marckong/vol-1615-posthog-dev-gate

Conversation

@marckong

@marckong marckong commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Tracking

Why

  • a CLI built from source without the Makefile (go build, go run, go install) reports version dev and still points at https://api.volcano.dev, so developers' runs and test feedback reports reached the production PostHog project through the API. Both cli_report_submitted events in production came from dev builds, and one was a test

Summary

  • add telemetry.DevBuildToProduction(apiURL): true when version.Version is dev and the API host is api.volcano.dev (any case, trailing dot allowed) (internal/telemetry/devbuild.go)
  • usage events: Flush drops the event before any request for such a build. Release builds, staging, and local APIs send as before
  • agent headers: Recorder.Reporting() is off for such a build, so API requests carry no X-Volcano-Agent* headers, which the API also forwards to product analytics
  • volcano feedback: such a build sends nothing, says why on stderr, and exits 0, the same exit as feedback that is off. --dry-run says the report would not be sent, volcano feedback status says why, and VOLCANO_FEEDBACK_DEBUG=1 still saves reports locally
  • volcano telemetry status adds a line saying a dev build sends no usage data to production
  • binaries from make build take their version from git describe (for example v0.57.0-3-gabc123), not dev, so they still send. This PR covers unstamped builds only
  • deferred: Record still starts the detached telemetry flush process in a dev build, which then sends nothing. Gating in Record too would mean changing the recorder tests, which rely on the default API URL
  • deferred: Reporting() reads the configured cloud API URL, so a dev build with the default URL also sends no agent headers to a volcano local server. Exporting VOLCANO_API_URL to a non-production URL restores them
  • companion PRs: volcano-web (flags client) and volcano-docs (provider) under the same ticket

Verification

  • make lint: 0 issues; golangci-lint fmt --diff: clean
  • go test ./...: pass; go build ./...: ok
  • new tests: TestDevBuildToProduction, TestFlush_DevBuildSendsNothingToProduction and TestFeedback_DevBuildSendsNothingToProduction (recording transports: no request from dev, one from v0.60.0, nothing leaves the process), TestReporting (no agent headers), TestTelemetryStatus_DevBuildToProduction. With the gate disabled, the gate tests fail

@marckong
marckong requested a review from a team as a code owner November 13, 2026 00:02
Copilot AI balanced review requested due to automatic review settings November 13, 2026 00:02

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

AI review: no P0-P2 findings

Reviewed f997903. Run log

Unstamped dev builds pointed at api.volcano.dev now send no data to production: no usage events in Flush, no X-Volcano-Agent* headers (Recorder.Reporting() returns false) and no volcano feedback reports. VOLCANO_FEEDBACK_DEBUG=1 still saves reports locally, and both status commands explain the gate. All three earlier findings are fixed at this head: agent headers are gated, the printReport comment is updated, and the feedback test now records requests through a replaceable sendClient instead of reaching the network. The change carries little risk. The one remaining nit is a P3.

⚪ P3

  • internal/cmd/feedback/feedback.go:151 Coding-agent feedback hint still shows in dev builds that can no longer send feedback

Not checked: The AI review read the diff, the code, and the PR's text; it ran no tests or builds and read nothing outside this repository.

  • Whether api.volcano.dev is the only hostname that forwards CLI telemetry, agent headers, and feedback to the production analytics project; another production alias would not be matched by the gate.
  • Whether every channel that ships binaries to users (release workflow, npm, Homebrew) stamps version.Version, so no customer build reports as dev and goes silent.
  • Whether api.volcano.dev is the only hostname forwarding CLI telemetry and feedback to the production analytics project.

Human review: needed

  • Should volcano feedback stop submitting production reports for all unstamped source installations, including go install builds, while still exiting successfully (internal/cmd/feedback/feedback.go…

The AI review found no P0-P2 problems at f997903, so the code needs no second review for bugs. Decide the points above: approve to accept them, or request changes.

Suggested reviewer: tkkhq (recently changed the telemetry recorder and feedback command code this PR gates). Any collaborator with write access other than the author can approve.

@github-actions
github-actions Bot requested a review from tkkhq November 13, 2026 00:05
func TestFeedback_DevBuildSendsNothingToProduction(t *testing.T) {
reports := setup(t, &config.TelemetryConfig{DeviceID: "d", NoticeShown: true})
// Never contacted: a development build stops before sending.
t.Setenv("VOLCANO_API_URL", "https://api.volcano.dev")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚪ P3: Dev-build feedback test points the CLI at the real production API

TestFeedback_DevBuildSendsNothingToProduction replaces the httptest sink with https://api.volcano.dev and relies on the new gate to stop the request. If the gate ever breaks, go test posts a test report with token tok to production. That is the kind of traffic this PR is meant to stop, and the test also starts depending on the network. The Flush test avoids this with a recording transport. The feedback command could get a similar hook, for example a package-level client that feedback.Send uses, so a regression shows up as a recorded request and nothing goes out.

Found by claude-opus-5-5

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in f997903: the command now sends through a replaceable sendClient, and the test sets a recording transport. It asserts no request for the dev build (including debug saves) and exactly one request to /cli/feedback for a release build, so nothing leaves the process even if the gate breaks. The printReport doc comment from the summary now lists the development-build reason too.

}
fmt.Fprintln(w, "Telemetry is enabled. Run `volcano telemetry disable` to turn it off.")
if telemetry.DevBuildToProduction(cfg.APIURL()) {
fmt.Fprintln(w, "This development build sends no usage data to the production API.")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 P2: Make the status message match agent-header reporting

With telemetry enabled and the first-run notice saved, cmd/volcano/main.go still enables agent reporting through Recorder.Reporting(). Under a detected coding agent, internal/api/version_protocol.go therefore continues attaching X-Volcano-Agent* headers to production API requests. The new message incorrectly promises that no usage data is sent. Either apply the development-build gate to agent reporting too, or narrow the message to the usage events suppressed by Flush.

Found by gpt-6.1-sol

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in f997903: Recorder.Reporting() now also returns false for a development build pointed at the production API (internal/telemetry/telemetry.go), and cmd/volcano/main.go turns the X-Volcano-Agent* headers on only from Reporting(), so no usage data (events or agent headers) goes to production from such a build and the status line is accurate. TestReporting covers it.

}
// A development build keeps its reports out of production
// analytics. Saving one locally still works.
devToProduction := telemetry.DevBuildToProduction(cfg.APIURL()) && !telemetry.FeedbackDebugByEnv(os.Getenv)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚪ P3: Coding-agent feedback hint still shows in dev builds that can no longer send feedback

cmd/volcano/main.go:49 sets feedbackHint from recorder.FeedbackOn() && recorder.LoggedIn(), and neither check knows about the new DevBuildToProduction gate. In a go build/go run binary using the default API URL, a coding agent whose command fails is still told to "report it after your task with volcano feedback". The agent then runs it and gets only Feedback not sent: a development build .... That wastes a step in exactly the setup this PR targets: agents running dev builds. The fix is to also require !telemetry.DevBuildToProduction(cfg.APIURL()) || telemetry.FeedbackDebugByEnv(os.Getenv) when computing the hint, for example through a recorder helper so main.go and this command share one condition.

Found by claude-opus-5-5

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Deferred, not fixed in this PR: it is a P3 that affects only unstamped dev builds pointed at production, where the cost is one wasted volcano feedback call that exits 0 with a one-line reason on stderr. Gating the hint means threading the API URL through main.go's hint setup, which restarts this review. Listed as a deferred item for the reviewer.

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