You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat: send attributable User-Agent on REST and OAuth requests - #477
Every request the SDK sends now leads its User-Agent with camunda-orchestration-sdk-python/<version> (the installed distribution version via importlib.metadata), so gateway usage reports can attribute SDK traffic.
REST (sync + async, generated operations and raw requests via the underlying httpx client): new runtime/user_agent.py request hook, injected by hooks/post_gen/0900_flatten_client.py alongside the auth / cluster-admin hooks.
OAuth token request (sync + async providers): token httpx client is created with the same User-Agent.
Extracted the shared append_request_hook helper in runtime/cluster_admin_url.py (reused by the new hook; keeps the escape-hatch baseline flat).
Application user agent: new CAMUNDA_USER_AGENT config key (env or explicit configuration) is appended after the SDK token. A caller-supplied User-Agent header (headers=) is also appended rather than replacing it.
Removed the dead httpUserAgent setting from generator-config.yaml (ignored by openapi-python-client).
README config table updated (generated from the field description).
Tests (red → green)
tests/acceptance/test_user_agent.py was committed first and failed (python-httpx/0.28.1 sent, missing module/config key); now green. Covers sync + async REST and token requests, env/config app UA appending, caller header precedence, and the removed generator setting.
make generate && make lint && make typecheck && make test — all green (962 passed).
Commits are split per AGENTS.md: generator/runtime change, then chore(generation) regenerated output.
Backport
Labelled backport stable/10 and backport stable/9: verified runtime/auth.py, runtime/configuration_resolver.py, hooks/post_gen/0900_flatten_client.py (with inject_auth_event_hooks) and the httpUserAgent line all exist on both branches. Cherry-pick only the generator commit. Note: this adds a config key (additive, non-breaking).
Every request now leads its User-Agent with
camunda-orchestration-sdk-python/<version>. CAMUNDA_USER_AGENT (or a
caller-supplied User-Agent header) is appended, never replacing it.
Removes the dead httpUserAgent setting from generator-config.yaml.
Closes#476
Signed-off-by: Josh Wulf <josh@magikcraft.io>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
User-agent handling still drops caller-supplied header content or bypasses the installed SDK version and CAMUNDA_USER_AGENT, requiring a matching fix, sync/async tests, and regenerated runtime code.
🤖 The changes in this PR were produced by nano-agent, an autonomous agent. Commits are authored under the operator's own git identity when one is resolvable (the human running the fleet), so they can satisfy CLA/DCO requirements; this note records that the work was generated by the agent.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The publicly exported Client and AuthenticatedClient bypass the wrapper-only attribution hook, leaving direct sync and async REST requests without the SDK identifier in default headers.
No open issues 🎉
1 previously missed issue
In code that hasn't changed since last review
Add SDK attribution to exported REST client factories
hooks/post_gen/0900_flatten_client.py:1312
The publicly exported Client and AuthenticatedClient bypass this wrapper-only hook, so direct sync/async REST requests with default headers still lack the SDK identifier. Add attribution to their httpx factories through the generator, preserving application-supplied suffixes, and cover both client types before regenerating. Same issue in the async wrapper at line 1552.
The publicly exported Client and AuthenticatedClient bypassed the
CamundaClient wrapper's User-Agent hook, so direct sync/async REST
requests with default headers lacked the SDK identifier.
Install the hook in an attrs __attrs_post_init__ on both generated
classes via ensure_user_agent_hook (idempotent — the wrapper's own
injection is detected by a marker and never doubled). The async httpx
factory converts sync hooks to async via asyncify_user_agent_hooks,
preserving each hook's composed value (application suffix survives).
Raise the escape-hatch baseline for 3 new Any uses in the httpx
hook-conversion path (HttpxArgs is dict[str, Any]; the hook list holds
arbitrary callables).
Refs #476
Signed-off-by: Josh Wulf <josh@magikcraft.io>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Custom user agents replace SDK attribution on token requests in both synchronous and asynchronous OAuth providers.
No open issues 🎉
1 previously missed issue
In code that hasn't changed since last review
Preserve SDK attribution in OAuth token request user agent
runtime/auth.py:213
Directly constructing OAuthClientCredentialsAuthProvider(..., user_agent="my-app/1.2") sends only the application value on token requests, losing SDK attribution. The async provider has the same issue at runtime/auth.py:456. Compose with build_user_agent(user_agent) in both providers, update the wrapper template to pass only CAMUNDA_USER_AGENT, and regenerate the SDK.
Both OAuthClientCredentialsAuthProvider and AsyncOAuthClientCredentialsAuthProvider
previously sent only the caller-supplied user_agent value on token requests,
losing SDK attribution. Compose with build_user_agent() so the SDK token
always leads and the application suffix follows.
The wrapper template now passes CAMUNDA_USER_AGENT directly (not pre-composed),
so the provider owns composition in one place.
Closes#476
Signed-off-by: Josh Wulf <josh@magikcraft.io>
Resolve the add/add conflict at the end of
tests/acceptance/test_pluggable_auth.py: keep this branch's
token-endpoint failure and expiry-boundary cases, and main's OAuth
User-Agent cases from #477. The two sets are independent; no test
was changed.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RcVhnekJQeXnMfPhs9pYda
#477 to stable/10) (#478)
* feat: send attributable User-Agent on REST and OAuth requests (backport #477 to stable/10)
Backport of #477 (cherry picked from commit be03747), hand-written
sources only. The escape-hatch baseline is recounted on stable/10 (any: 363 -> 366).
* chore(gen): regenerate for backport of #477
#477 to stable/9) (#479)
* feat: send attributable User-Agent on REST and OAuth requests (backport #477 to stable/9)
Backport of #477 (cherry picked from commit be03747), ported by
hand. stable/9 has no runtime/cluster_admin_url.py, so user_agent.py carries its own HttpxArgs,
RequestHook and append_request_hook, and the OAuth providers take no clock argument. There is no
escape-hatch baseline on stable/9.
* chore(gen): regenerate for backport of #477
* fix: type the user-agent hook helpers for stable/9's strict pyright
* test: annotate the topology fixture for stable/9's strict pyright
* chore(gen): regenerate for user-agent typing fix
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
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
Every request the SDK sends now leads its
User-Agentwithcamunda-orchestration-sdk-python/<version>(the installed distribution version viaimportlib.metadata), so gateway usage reports can attribute SDK traffic.runtime/user_agent.pyrequest hook, injected byhooks/post_gen/0900_flatten_client.pyalongside the auth / cluster-admin hooks.User-Agent.append_request_hookhelper inruntime/cluster_admin_url.py(reused by the new hook; keeps the escape-hatch baseline flat).CAMUNDA_USER_AGENTconfig key (env or explicit configuration) is appended after the SDK token. A caller-suppliedUser-Agentheader (headers=) is also appended rather than replacing it.httpUserAgentsetting fromgenerator-config.yaml(ignored by openapi-python-client).Tests (red → green)
tests/acceptance/test_user_agent.pywas committed first and failed (python-httpx/0.28.1sent, missing module/config key); now green. Covers sync + async REST and token requests, env/config app UA appending, caller header precedence, and the removed generator setting.make generate && make lint && make typecheck && make test— all green (962 passed).Commits are split per AGENTS.md: generator/runtime change, then
chore(generation)regenerated output.Backport
Labelled
backport stable/10andbackport stable/9: verifiedruntime/auth.py,runtime/configuration_resolver.py,hooks/post_gen/0900_flatten_client.py(withinject_auth_event_hooks) and thehttpUserAgentline all exist on both branches. Cherry-pick only the generator commit. Note: this adds a config key (additive, non-breaking).Closes #476