Skip to content

fix(python-sdk): respect an explicit User-Agent header in the volume connection config - #2164

Open
DZH166 wants to merge 1 commit into
e2b-dev:mainfrom
DZH166:codex/volume-user-agent-20261121
Open

DZH166 wants to merge 1 commit into
e2b-dev:mainfrom
DZH166:codex/volume-user-agent-20261121

Conversation

@DZH166

@DZH166 DZH166 commented Nov 21, 2026 •

Copy link
Copy Markdown

Summary

VolumeConnectionConfig overwrote the User-Agent header unconditionally, so a caller-supplied User-Agent was silently discarded:

self.headers = dict(headers) if headers else {}
self.headers["User-Agent"] = f"e2b-python-sdk/{package_version}"

Every other connection path in the SDKs keeps an explicit value: the main Python ConnectionConfig._apply_user_agent documents "an explicitly provided value always wins", and the JS SDK's volume client spreads config.headers last, so an explicit User-Agent wins there too. The Python volume config was the odd one out.

The fix is one line: fill the SDK default with setdefault, so it only applies when the caller did not send a User-Agent.

from e2b.volume import VolumeConnectionConfig

config = VolumeConnectionConfig(headers={"User-Agent": "my-agent/1.2"})
assert config.headers["User-Agent"] == "my-agent/1.2"  # was e2b-python-sdk/<version>

Callers that don't send one are unaffected: the default e2b-python-sdk/<version> is still set.

Validation

  • Red → green with the package's own tests (pytest, offline, mocked):
    • Before the fix: test_volume_user_agent_explicit_value_is_preserved fails (assert 'e2b-python-sdk/2.64.0' == 'my-agent/1.2').
    • After the fix: the whole tests/test_volume_connection_config.py passes (15 tests), plus tests/test_volume_client.py, tests/test_connection_config.py, tests/test_env_var_parsing.py (88 passed total).
  • ruff check and ruff format --check (pinned 0.11.13) pass on both touched files.
  • git diff --check clean.
  • JS needs no change: its volume client already lets caller headers win, so this restores SDK parity rather than introducing drift.

AI assistance

This fix was prepared by an automated agent (Claude Code, running as DZH166's contribution-preparation workflow) and reviewed before submission.


Devin Review

@DZH166
DZH166 requested a review from mishushakov as a code owner November 21, 2026 12:15
@cla-bot

cla-bot Bot commented Nov 21, 2026

Copy link
Copy Markdown

We require contributors to sign our Contributor License Agreement, and we don't have @DZH166 on file. You can sign our CLA at https://e2b.dev/docs/cla . Once you've signed, post a comment here that says '@cla-bot check'

@changeset-bot

changeset-bot Bot commented Nov 21, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: be604fd

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@e2b/python-sdk Patch
@e2b/code-interpreter-python Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-21T12:17:46.961108Z be604fd PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TASTE.md review: complies — checked T-1/T-2 (JS + sync/async Python parity; the shared VolumeConnectionConfig now matches the JS volume client, which spreads caller headers last), T-49/T-51 (config resolution, no post-construction mutation), and T-52 (no added client-side validation); 0 violations.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Devin Review: 2 flags

Not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)

Devin Review

This branch has not been deployed

No deployments
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