feat(sdk): surface API deprecations via a generic response interceptor#3806
feat(sdk): surface API deprecations via a generic response interceptor#3806Lingala (lingala-composio) wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Review Summary ·
|
11dcb58 to
533c479
Compare
|
The Please review and fix the vulnerabilities. You can try running: pnpm audit --fix --prodAudit output |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 533c479. Configure here.
| self._on_deprecation = on_deprecation | ||
| # Operations we have already warned about, so a repeatedly-called | ||
| # deprecated operation only warns once. Keyed by ``METHOD path-template``. | ||
| self._warned_deprecated_operations: t.Set[str] = set() |
There was a problem hiding this comment.
Clone drops deprecation options
Medium Severity
HttpClient.copy re-injects provider and _strict_response_validation for cloned clients, but not disable_deprecation_warnings or on_deprecation. The without_retries sibling (used by tools.execute and tools.proxy) is built via with_options(max_retries=0), so it keeps default warning behavior and loses the telemetry hook even when the parent client opted out or registered on_deprecation.
Reviewed by Cursor Bugbot for commit 533c479. Configure here.
Review Summary ·
|
Replace the endpoint-specific SEC-339 `initiate()` deprecation check with a
single header-driven response interceptor in both the TypeScript and Python
SDKs, so any endpoint deprecated server-side is surfaced automatically with no
new SDK release.
The interceptor inspects standard deprecation-signalling headers on every
response and warns once per operation:
- `Deprecation` (RFC 9745) — presence gates the warning; the `@<epoch>`
value is parsed into a date (literal "true" is not required).
- `Sunset` (RFC 8594) — optional removal date; drives escalated wording as
the date approaches or passes.
- `Link; rel="successor-version"` / `rel="deprecation"` (RFC 8288) — optional
replacement endpoint or migration-docs URL.
Warnings dedupe by HTTP method + normalized route template, so repeated calls
(and calls with different path params) collapse to one warning. Two new client
options are added to both SDKs: `disableDeprecationWarnings` /
`disable_deprecation_warnings` to silence warnings, and `onDeprecation` /
`on_deprecation` for a structured `{method, path, deprecatedAt, sunset,
successor}` callback for custom telemetry. The interceptor never throws, never
mutates the response, and swallows malformed headers.
`connectedAccounts.initiate()` no longer carries its own deprecation gate — it
now flows through the generic mechanism like every other endpoint. The typed
retired-endpoint 400 error is unchanged.
TS: routes through the generated client's `fetch` option and logs via the SDK
logger. Python: overrides `HttpClient._process_response` and emits a
`DeprecationWarning`.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
533c479 to
5169db6
Compare
Review Summary ·
|


Summary
Ref: https://www.notion.so/composio/Deprecation-of-APIs-399f261a6dfe80968feec49ed84e14b8?source=copy_link
Replaces the endpoint-specific SEC-339
initiate()deprecation check with a single header-driven response interceptor in both the TypeScript and Python SDKs. Any endpoint deprecated server-side is now surfaced automatically — no new SDK release required.The interceptor inspects standard deprecation-signalling headers on every response and warns once per operation:
Deprecation(RFC 9745) — presence gates the warning; the@<epoch>value is parsed into a date (the literal"true"is not required).Sunset(RFC 8594) — optional removal date; drives escalated wording as the date approaches or passes.Link; rel="successor-version"/rel="deprecation"(RFC 8288) — optional replacement-endpoint or migration-docs URL.Warnings dedupe by HTTP method + normalized route template, so repeated calls (and calls with different path params) collapse to one warning. A header-less flow on an endpoint never suppresses a later deprecated flow on the same operation.
New client options (both SDKs)
disableDeprecationWarnings/disable_deprecation_warnings— silence the warnings.onDeprecation/on_deprecation— structured{ method, path, deprecatedAt, sunset, successor }callback for custom telemetry.Safety
Never throws, never mutates the response body, swallows malformed headers.
Migration
connectedAccounts.initiate()no longer carries its own deprecation gate (the.withResponse()/with_raw_responsedance and one-time module guard are removed) — it flows through the generic mechanism like every other endpoint. The typed retired-endpoint400error is unchanged.Implementation
utils/deprecation.ts; wired via the generated client'sfetchoption incomposio.ts; warns via the SDK logger._warn_if_deprecated+ aHttpClient._process_responseoverride incomposio/client/__init__.py; options threaded throughsdk.py; emitswarnings.warn(..., DeprecationWarning).Tests
deprecationunit suites in both SDKs cover: warns onDeprecation; silent when absent; dedupe (incl. different path params);@<epoch>parsed as a date and literal"true"still warns via presence;Sunset/Linkread into the message; escalation wording; opt-out respected;onDeprecationfired with structured payload; never throws on garbage; and the header-less-then-deprecated same-operation case.initiatetests off the removed bespoke gate; removed the obsoleteinitiate deprecation header gateblocks.Verification
tsc --noEmitclean, eslint clean, prettier clean.ruff check/ruff formatclean;mypyclean on changed files._process_responseoverride confirmed call-compatible with the pinned base client.🤖 Generated with Claude Code