Skip to content

ref(deps): Remove unused openai dependency - #125177

Merged
oioki merged 1 commit into
masterfrom
ref/remove-unused-openai-dependency
Sep 22, 2026
Merged

oioki merged 1 commit into
masterfrom
ref/remove-unused-openai-dependency

Conversation

@oioki

@oioki oioki commented Sep 22, 2026

Copy link
Copy Markdown
Member

Remove the openai package from [project].dependencies and prune it from uv.lock, along with httpx and distro, which were only reachable through it.

The SDK was added for the AI suggested-fix feature (#46375). That endpoint was removed in #81096, and the last remaining import went away with the old LLM spam-detection module in #101297. Nothing in sentry or getsentry has imported openai, httpx, or distro since — the "openai/..." model IDs in ai_agent_monitoring.py are plain strings passed to OpenRouter and don't touch the package.

This also unblocks the fix for Dependabot alert #721 (anyio < 4.14.2, GHSA-82r6-8w77-94w6): openai==1.3.5 pins anyio<4, so the security bump can't land while this dependency is present. The alternative was bumping openai to 1.93.0 alongside anyio, but that pulls in a new jiter wheel set for a package we don't use. The anyio bump itself follows in a separate PR so it stays independently revertable.

Side effect worth knowing: sentry_sdk's OpenAIIntegration auto-enables only when openai is importable, so it will no longer activate in dev environments. Since sentry never calls the SDK there was nothing for it to instrument.

Refs #101297

The openai SDK was added for the AI suggested-fix feature (#46375). That
endpoint was removed in #81096 and the last import went away with the
old LLM spam-detection module in #101297. Nothing in sentry or getsentry
has imported it since; the "openai/..." model IDs in ai_agent_monitoring
are plain strings sent to OpenRouter.

httpx and distro drop out of the lockfile as well since they were only
reachable through openai.

Refs #101297
Co-Authored-By: Claude <[email protected]>
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Sep 22, 2026
@oioki
oioki marked this pull request as ready for review September 22, 2026 09:28
@oioki
oioki requested a review from a team as a code owner September 22, 2026 09:28
@oioki
oioki merged commit 6564f4d into master Sep 22, 2026
88 checks passed
@oioki
oioki deleted the ref/remove-unused-openai-dependency branch September 22, 2026 10:04
oioki added a commit that referenced this pull request Sep 22, 2026
Add `requires-python = ">=3.13"` to `[project]` in `pyproject.toml`. No
lockfile change — `uv.lock` already records exactly this range.

Every Dependabot security update for `uv.lock` currently fails with:

```
warning: No `requires-python` value found in the workspace. Defaulting to `>=3.14`.
error: No solution found when resolving dependencies for split (markers: sys_platform == 'darwin' or sys_platform == 'linux')
  cause: Because all versions of backports-zstd have no wheels with a matching Python version tag (e.g., `cp314`) and your project depends on backports-zstd, we can conclude that your project's requirements are unsatisfiable.
```

The root cause is the first line: with no `requires-python`, uv derives
the supported range from whichever interpreter runs it. Locally that's
3.13 and everything resolves. Dependabot's runner has Python 3.14.5 (it
doesn't pick up our `.python-version`), so it resolves for `>=3.14` and
correctly fails — `backports-zstd` is a backport of 3.14's stdlib
`compression.zstd`, upstream caps it at `<3.14`, and it has no cp314
wheels for any version. Our internal mirror is already right about this
(`python_versions = <3.14` in `packages.ini`); there is nothing to fix
on that side.

Declaring the range makes `uv lock` deterministic regardless of
interpreter. uv only checks a dependency's `requires-python` against the
project's *lower* bound, so `>=3.13` is compatible with
`backports-zstd`'s `<3.14` exactly as the current lock implies. Verified
by reproducing the failure on clean master with `uv lock --python 3.14`
(CI-pinned uv 0.12.10), then confirming it resolves on both 3.14 and
3.13 with this change and that `uv lock` produces an empty diff.

This also means the lockfile's recorded `requires-python` stops being an
accident of who last ran `uv lock`.

I chose `>=3.13` over `==3.13.*` because it's what the lock already
encodes and doesn't fight the in-progress 3.14 work in the mirror repo.
A follow-up worth doing separately (it changes the lock):
`backports-zstd` should carry a `python_version < "3.14"` marker,
matching how `urllib3[zstd]` declares it — it only exists in our deps
for urllib3's benefit.

This unblocks Dependabot for the open `uv.lock` alerts; #125177 /
#125178 were done by hand because of this.

Co-authored-by: Claude <[email protected]>
oioki added a commit that referenced this pull request Sep 22, 2026
Bump `anyio` 3.7.1 → 4.14.2 in `uv.lock`, closing Dependabot alerts #721
and #720.

- **GHSA-82r6-8w77-94w6 / CVE-2026-63374 (critical)** —
`TLSStream.wrap()` and `connect_tcp()` encode internationalized host
names with IDNA 2003. An attacker who can redirect a connection to a
non-ASCII domain can obtain a legitimate certificate for the IDNA 2003
encoding of that name and have it validate on the client.
- **GHSA-5p39-cfhj-2xmp / CVE-2026-64847 (medium)** — process-pool
workers can block indefinitely on undrained stderr.

This bump was blocked until now: `openai==1.3.5` pinned `anyio<4`, so
the resolver could not move it. That dependency turned out to be unused
and was removed in #125177, which this PR builds on. `sniffio` is no
longer an anyio dependency but stays in the lock via another dependent.

## On the major version bump (3.x → 4.x)

anyio 4.0.0 has six backwards-incompatible changes; 4.1 through 4.14.2
add none. Only one is reachable from this repo:

- **Task-group exceptions are now wrapped in `ExceptionGroup`** and
related cancellation-semantics changes. No consumer here catches
`ExceptionGroup` or relies on unwrapped task-group exceptions.
- **The pytest plugin now runs tests and fixtures in the same task.**
This is the only change that touches our own code —
`tests/apigw/test_circuitbreaker.py` uses `@pytest.mark.anyio`. All 13
tests in `tests/apigw/` pass.
- `anyio.Path.relative_to()`/`is_relative_to()`, old-style coroutine
tasks, and the asyncio `policy` option: no usage anywhere.

Consumers of anyio in the resolved environment, and why each is safe:

| Package | Pulled in by | How it uses anyio |
|---|---|---|
| `watchfiles` | `granian` | Only declared dependent. granian calls the
**sync** `watchfiles.watch()` (Rust + threads); the anyio-based
`awatch`/`arun_process` paths are never executed. Reload is dev-only
(`SENTRY_GRANIAN_RELOAD`). |
| `httpcore` | `sentry-sdk[http2]` | Optional `AnyIOBackend`, async pool
only. sentry is WSGI, and `sdk_http2_experiment.enabled` defaults to
`False`. |
| `granian` | direct | `try: import anyio / except: anyio = None`; no
API use. |
| `huggingface_hub` | `tokenizers` | An `open_process` monkeypatch in
the MCP CLI, never reached. |

Verified: every anyio attribute these packages reference resolves under
4.14.2; all four import cleanly; `httpcore`'s `AnyIOBackend` completes a
real TLS request over anyio 4 (status 200); `watchfiles.watch()` detects
changes; `tests/apigw/` passes.

Worth noting the bump also *resolves* a latent mismatch: `httpcore
1.0.9` declares `anyio>=4.0,<5.0` for its `asyncio` extra, so at 3.7.1
we were below the floor httpcore supports.

Done by hand because Dependabot's auto-fix could not regenerate
`uv.lock` for this repo — it ran `uv` under Python 3.14 and failed on
`backports-zstd` having no cp314 wheels. #125179 fixed that root cause
by declaring `requires-python`.

Fixes GHSA-82r6-8w77-94w6

Co-authored-by: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants