Repository navigation
feat(client): send a stackctl User-Agent header - #171
Merged
Merged
Conversation
Every request from cli/pkg/client, the session requests in auth.go and both WebSocket dials (also the ?token= fallback) now send "User-Agent: stackctl/<version> (<os>/<arch>)". cmd.SetVersionInfo passes the build version to client.SetVersion, so the header matches `stackctl version`; a build without ldflags sends "stackctl/dev". Characters outside the RFC 9110 token set become "_". The header is set where each request is built, not in a transport, because cmd/stack.go replaces HTTPClient. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Go 1.26.9 is affected by GO-2026-6809 (crypto/x509 trusts compromised intermediate certificates). govulncheck reaches it through the TLS WebSocket dial in client.dialWS. CI reads the Go version from cli/go.mod. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… header Review fixes for #171: - SetVersion builds the header value once (atomic.Pointer[string]); UserAgent() only loads it. - Both WebSocket dials take their headers from baseWSHeader(), so the ?token= fallback cannot miss a header that the first dial sends. - All version tests restore the build globals, so TestVersionCmd_JSON no longer leaks "2.0.0" into the client User-Agent of later cmd tests. - The test server handlers report failures on their subtest. - CLAUDE.md documents the t.Parallel exception for tests that change package-global state; the docs name Go 1.26.10. Co-Authored-By: Claude Opus 5.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.
Closes #170
Summary
User-Agent: stackctl/<version> (<os>/<arch>), for examplestackctl/1.4.0 (linux/amd64). This covers API requests (send()), the session requests (sendSession()inauth.go) and the WebSocket upgrade, including the?token=fallback dial. The fallback still sends noAuthorizationorX-API-Keyheader.cmd.SetVersionInfocalls the newclient.SetVersion, so the header shows the same version asstackctl version. A build without ldflags sendsstackctl/dev._, so a malformed version cannot break the header.cmd/stack.goreplacesHTTPClient.Tests
httptesttests check the header on an API request, a session request (Logout), the WebSocket upgrade with a JWT and with an API key, and the 401 fallback on both dials. They also cover thedevdefault and the character replacement.SetVersionInfohas a test that checks it sets the header version.go vet ./...is clean andgo test ./... -race -count=1passes.Follow-ups (not in this PR)
STACKCTL_VERSIONto plugins so they can send<plugin>/<version> stackctl/<version>.--debugoutput.Also in this PR
cli/go.mod: Go 1.26.9 to 1.26.10 for GO-2026-6809 (crypto/x509), which failed the govulncheck job. Main has the same problem.fe2e446):SetVersionbuilds the header once, both WebSocket dials sharebaseWSHeader(), the version tests restore their globals, and the docs name Go 1.26.10.🤖 Generated with Claude Code