Skip to content

Chain package tokens in the User-Agent - #5

Merged
sandervanhooft merged 1 commit into
mainfrom
chained-user-agent
Nov 26, 2026
Merged

sandervanhooft merged 1 commit into
mainfrom
chained-user-agent

Conversation

@sandervanhooft

@sandervanhooft sandervanhooft commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

The User-Agent now names every package involved, in the format vatly-api-php uses since vatly/vatly-api-php#84: one vendor/package/version token per package.

  • The SDK sends vatly/vatly-api-python/<version> Python/<version> httpx/<version> instead of vatly-api-python/<version>. The version comes from vatly.__version__.
  • New add_version_string(token) on VatlyClient and AsyncVatlyClient: a package or integration built on the SDK appends its own token, e.g. vatly/vatly-fluent-python/0.1.0a4. Whitespace becomes -, and a token already present is skipped, so wrapping one shared client many times does not grow the header.
  • Non-breaking: a User-Agent in default_headers or RequestOptions.headers still replaces the header, as before. Vatly-Client-Info is unchanged.
  • Documented in the README and the changelog (Unreleased). Not in docs/, because those pages sync to docs.vatly.com and their examples run against the published 0.1.0a4 in CI; add it there after the release.
  • New test checks the header sent: the default chain, appended tokens in order, whitespace and duplicate handling, and both overrides. It fails on main.

Used by vatly-fluent-python and vatly-django in follow-up PRs. Example on the wire with both:

vatly/vatly-api-python/0.1.0a4 Python/3.12.14 httpx/0.28.1 vatly/vatly-fluent-python/0.1.0a4 vatly/vatly-django/0.1.0a5

No version bump or release here.

The User-Agent is now vatly/vatly-api-python/<version> Python/<version>
httpx/<version>, the format vatly-api-php uses (vatly-api-php#84).
add_version_string() lets packages built on the SDK, such as
vatly-fluent-python and vatly-django, append their own token so a request
names every package involved. Repeated tokens are ignored, and a
User-Agent in default_headers or RequestOptions.headers still wins.

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-57ff6642-71f4-41bc-a445-a2b9be732083
@sandervanhooft
sandervanhooft merged commit 9535226 into main Nov 26, 2026
14 checks passed
sandervanhooft added a commit to vatly/vatly-fluent-python that referenced this pull request Nov 26, 2026
* Append vatly-fluent-python to the SDK User-Agent

Vatly(...) adds vatly/vatly-fluent-python/<version> to the SDK client's
User-Agent with add_version_string (vatly/vatly-api-python#5), the chained
format all Vatly SDKs use. The version moves to _version.py so the client
module can read it. SDKs without add_version_string are left unchanged.

Development and CI use the SDK PR commit through [tool.uv.sources] until
it is released; package metadata still pins vatly-api-python==0.1.0a4.

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-57ff6642-71f4-41bc-a445-a2b9be732083

* Point the SDK source at its main merge commit

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-57ff6642-71f4-41bc-a445-a2b9be732083

---------

Co-authored-by: Sander van Hooft <7265703+sandervanhooft@users.noreply.github.com>
Co-authored-by: Amp <amp@ampcode.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.

1 participant