Skip to content

fix: standardize User-Agent header across API client, OAuth, and update checks - #12

Merged
carlostasada merged 1 commit into
mainfrom
ctasada/standardise-user-agent
Jul 27, 2026
Merged

fix: standardize User-Agent header across API client, OAuth, and update checks#12
carlostasada merged 1 commit into
mainfrom
ctasada/standardise-user-agent

Conversation

@carlostasada

Copy link
Copy Markdown
Contributor

Replace the ad-hoc "alpaca-cli/" string with a shared internal/useragent package that builds APCA-CLI/ /, matching the convention used by Alpaca's other SDKs.

…te checks

Replace the ad-hoc "alpaca-cli/<version>" string with a shared
internal/useragent package that builds APCA-CLI/<version> <os>/<arch>,
matching the convention used by Alpaca's other SDKs.
@greptile-apps

greptile-apps Bot commented Jul 24, 2026

Copy link
Copy Markdown

Greptile Summary

Standardizes User-Agent generation across API, OAuth, credential-validation, and update-check requests.

  • Adds a shared internal/useragent package that emits APCA-CLI/<version> <os>/<arch>.
  • Updates all production HTTP request paths to use the shared format.
  • Adds tests for the generated format and updates the API client test coverage.
  • Adds .idea to .gitignore.

Confidence Score: 5/5

The change appears safe to merge, with production request paths consistently adopting the shared User-Agent format.

The shared formatter produces a valid platform-qualified value, existing version initialization supplies usable release or development versions, and each changed request path applies the new header without disrupting request construction.

T-Rex T-Rex Logs

What T-Rex did

  • Ran two comparable Go test suites; both exited with exit code 0.
  • Performed after-run verification and confirmed that headers matched observed and expected values for cmd.SetVersion, API /v2/account, validation /v2/account, GitHub releases, and OAuth token exchange.
  • Retained the generated same-package harness sources to support reproducible proof.

View all artifacts

T-Rex Ran code and verified through T-Rex

Important Files Changed

Filename Overview
internal/useragent/useragent.go Introduces the shared platform-aware User-Agent formatter with straightforward deterministic behavior.
internal/client/client.go Replaces the API client's legacy User-Agent value with the shared formatter.
internal/cmd/root.go Propagates the configured CLI version into OAuth's newly standardized User-Agent.
internal/cmd/auth.go Applies the shared User-Agent format to credential-validation requests.
internal/cmd/update.go Applies the shared User-Agent format to GitHub release checks.
internal/oauth/oauth.go Initializes OAuth requests with the standardized development User-Agent.
internal/useragent/useragent_test.go Covers normal and empty-version formatting behavior.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
V[CLI version] --> B[useragent.Build]
B --> F[APCA-CLI/version os/arch]
F --> A[API client requests]
F --> O[OAuth token exchange]
F --> C[Credential validation]
F --> U[Update checks]
Loading

Reviews (1): Last reviewed commit: "fix: standardize User-Agent header acros..." | Re-trigger Greptile

@carlostasada
carlostasada merged commit f5f7083 into main Jul 27, 2026
7 checks passed
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