feat: add SDK identification headers to all HTTP requests#268
Conversation
Add a centralized get_default_headers() method to APIConfig that includes a 'hh-sdk-version' header with the SDK version. This allows HTTP calls from the python-sdk client to be identified on the backend. Changes: - Added get_default_headers() to APIConfig in api_config.py - Updated all generated service files (sync + async) to use it - Updated manual header construction in client.py export methods - Updated CLI request headers - Updated tracer OTLP exporter headers Co-Authored-By: unknown <>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
|
Claude finished @devin-ai-integration[bot]'s task in 2m 12s —— View job Reviewing PR #268
SummaryReviewed all 22 changed files. The centralization of headers into Posted 3 inline comments covering:
Posted top-level review covering:
|
|
📚 Documentation preview built — Download artifact Review instructions & validation statusHow to Review
Validation Status
|
Code Review SummaryOverall: Clean, well-scoped change. The centralization of headers into What looks good
Concerns
DocumentationNo documentation updates needed — this is an internal header not exposed in any public API. See inline comments for specific code-level feedback. |
- Updated httpx.jinja2 and apiconfig_pydantic_2.jinja2 templates so the hh-sdk-version header survives code regeneration - Added _get_sdk_version() with try/except fallback to 'unknown' - Fixed Bearer None when access_token is None (uses empty string) - Added CHANGELOG entry for the feature - Added graceful degradation to cli/main.py and initialization.py Co-Authored-By: unknown <>
|
📚 Documentation preview built — Download artifact Review instructions & validation statusHow to Review
Validation Status
|
…eader - Removed implementation details from CHANGELOG (customer-facing only) - Added 7 unit tests covering get_default_headers() and _get_sdk_version() Co-Authored-By: unknown <>
|
📚 Documentation preview built — Download artifact Review instructions & validation statusHow to Review
Validation Status
|
Updated the description for the 'hh-sdk-version' header to clarify its purpose.
|
📚 Documentation preview built — Download artifact Review instructions & validation statusHow to Review
Validation Status
|
…ests Co-Authored-By: unknown <>
|
📚 Documentation preview built — Download artifact Review instructions & validation statusHow to Review
Validation Status
|
|
@claude approve with final review |
|
@claude review the final diff and whether feedback was addressed |
|
Claude finished @skylarmb's task in 1m 42s —— View job Reviewing PR #268 — Final diff and feedback resolution
Previous Feedback — Resolution Status
Final Diff ReviewAll feedback from both Claude and @skylarmb has been addressed. The final state of the code is clean:
No new issues found. LGTM. |
feat: add SDK identification headers to all HTTP requests
Summary
Adds three identification headers to every HTTP request made by the Python SDK so the backend can identify which SDK, language, and version originated each call:
hh-sdk-version__version__(e.g.1.0.0rc16), falls back to"unknown"hh-sdk-languagepythonhh-sdk-packagehoneyhiveApproach: A new
get_default_headers()method onAPIConfigcentralizes the standard header set (Content-Type, Accept, Authorization, and the three new SDK headers). Both the code-generation Jinja2 templates (httpx.jinja2,apiconfig_pydantic_2.jinja2) and the generated output were updated, so the headers survive futuremake generateruns. The CLI and tracer OTLP exporter were also updated directly.Updates since last revision
hh-sdk-languageandhh-sdk-packageheaders alongsidehh-sdk-version(per discussion about distinguishing Pythonhoneyhivefrom TShoneyhive/@honeyhive/logger)tests_v2/unit/test_api_config_headers.pycovering all header keys and values_get_sdk_version()fallback,Bearer NonefixReview & Testing Checklist for Human
hh-sdk-*headers appear with the expected values. CI doesn't exercise a real backend.Bearerwhen no token: Whenaccess_tokenisNone, the Authorization header becomes"Bearer "(empty string after Bearer). Confirm the backend handles this gracefully — this is pre-existing behavior that was"Bearer None"before this PR.header_paramspath: Thehttpx.jinja2template has a conditional{% if header_params|length > 0 %}block. No current endpoints use header params, so this path is untested. If a future OpenAPI spec adds header parameters, verifymake generatestill produces valid Python.Notes
_get_sdk_version()helper since those headers have a different structure (X-Project, X-Source) and don't go throughAPIConfig.