Open
Conversation
Move token resolution and bearer header setup out of RequestClient so the shared client only handles transport concerns, header and param merging, retries, and closing its transport. Keep legacy helper behavior in the http client factories and move stable SDK auth resolution into the SDK wrapper while preserving compatibility for remaining legacy callers that still read RequestClient.token.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
This PR introduces the first “clean-room” vercel.stable client surface, centered on a lazy root client that owns transport lifecycle and exposes thin, option-overlayable service clients (SDK + cache), with shared stable options/errors/pagination utilities and accompanying tests.
Changes:
- Add stable root clients (
SyncVercel/AsyncVercel) with lazy, shared runtime/transport and derived SDK/cache clients that supportwith_options()overlays via isolated request state. - Add stable SDK surfaces for
projectsanddeployments, plus stable cache clients and internal request backends (sync/async aligned). - Refactor generic
RequestClientto be transport-focused (no token/env resolution), moving bearer setup into client factories and stable-layer request clients; add extensive unit/integration + property-based tests.
Reviewed changes
Copilot reviewed 48 out of 48 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/test_request_client.py | Updates tests to reflect RequestClient no longer auto-injects auth; verifies header behavior and compatibility token accessor. |
| tests/unit/stable/test_root_client.py | Tests lazy env access and thread-safe single runtime initialization; adds property test for mapping merge. |
| tests/unit/stable/test_projects_client.py | Property-based test for snake→camel helper behavior. |
| tests/unit/stable/test_cache_client.py | Property-based tests for cache hashing and key transformation. |
| tests/unit/stable/test_api_errors.py | Tests stable error parsing/mapping and stable SDK request defaults (headers, env token fallback). |
| tests/unit/stable/init.py | Marks stable unit test package for discovery. |
| tests/unit/init.py | Marks unit test package for discovery. |
| tests/integration/stable/test_projects_api.py | Integration tests for stable projects API surface, lazy connection behavior, and option overlays. |
| tests/integration/stable/test_deployments_api.py | Integration tests for stable deployments API surface including file upload and option overlays. |
| tests/integration/stable/test_cache_client.py | Integration tests for in-memory + remote cache behavior, overlays, lineage reuse, and closed-transport behavior (sync/async). |
| tests/integration/stable/init.py | Marks stable integration test package for discovery. |
| tests/integration/init.py | Marks integration test package for discovery. |
| tests/init.py | Marks test package for stable submodule collection. |
| src/vercel/stable/sdk/projects.py | Public stable Projects client + models + pagination helpers (sync/async). |
| src/vercel/stable/sdk/deployments.py | Public stable Deployments client + models (sync/async). |
| src/vercel/stable/sdk/client.py | Public stable SDK wrapper (SyncSdk/AsyncSdk) with with_options() overlays and service accessors. |
| src/vercel/stable/sdk/init.py | Stable SDK public exports. |
| src/vercel/stable/sandbox/client.py | Placeholder stable sandbox clients with with_options(). |
| src/vercel/stable/sandbox/init.py | Stable sandbox exports. |
| src/vercel/stable/queues/init.py | Placeholder stable queues package. |
| src/vercel/stable/pagination.py | Public pagination wrappers (Page, Paginator, AsyncPaginator). |
| src/vercel/stable/options.py | Public immutable option dataclasses for stable surface. |
| src/vercel/stable/errors.py | Public stable error types (API response errors + transport closed). |
| src/vercel/stable/client.py | Public stable root clients (SyncVercel/AsyncVercel) + create_sync_client/create_async_client. |
| src/vercel/stable/cache/client.py | Public stable cache clients with overlays and backend wiring. |
| src/vercel/stable/cache/init.py | Stable cache exports. |
| src/vercel/stable/blob/client.py | Placeholder stable blob clients with with_options(). |
| src/vercel/stable/blob/init.py | Stable blob exports. |
| src/vercel/stable/init.py | Stable top-level exports. |
| src/vercel/_internal/stable/sdk/request_client.py | Internal stable SDK request client: builds auth/headers/params, lazy transport acquisition, error extraction. |
| src/vercel/_internal/stable/sdk/projects.py | Internal async-shaped Projects backend (request building + parsing). |
| src/vercel/_internal/stable/sdk/deployments.py | Internal async-shaped Deployments backend (params/body mapping + parsing). |
| src/vercel/_internal/stable/sdk/init.py | Internal stable SDK exports. |
| src/vercel/_internal/stable/sandbox/init.py | Internal stable sandbox placeholder. |
| src/vercel/_internal/stable/runtime.py | Shared lazy runtime that initializes/owns transports and enforces closed-lineage behavior. |
| src/vercel/_internal/stable/queues/init.py | Internal stable queues placeholder. |
| src/vercel/_internal/stable/pagination.py | Internal minimal (a)sync page iterators. |
| src/vercel/_internal/stable/options.py | Internal stable option overlay helpers (merge_mapping, dataclass merging). |
| src/vercel/_internal/stable/errors.py | Internal mapping from HTTP status to stable error types. |
| src/vercel/_internal/stable/cache/client.py | Internal stable cache implementation (in-memory store + optional remote cache request client). |
| src/vercel/_internal/stable/cache/init.py | Internal stable cache exports. |
| src/vercel/_internal/stable/blob/init.py | Internal stable blob placeholder. |
| src/vercel/_internal/stable/init.py | Internal stable convenience exports. |
| src/vercel/_internal/http/request_client.py | Refactors RequestClient to stop resolving tokens; adds bearer-token compatibility accessor. |
| src/vercel/_internal/http/clients.py | Moves token resolution and bearer header injection into request-client factory functions. |
| src/vercel/init.py | Adds top-level exports for stable root client creation. |
| pyproject.toml | Adds Hypothesis as a dev dependency for property-based tests. |
| examples/runtime_cache.py | Updates cache example to use new stable root + cache APIs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
While attempting to run down some review feedback, I stumbled upon the old vercel.cache.purge API which I neglected before. While trying to understand how the context worked, I decided that before we can truly refactor this, I need a lot more understanding about how it works in our python runtime setup.
d7d3af3 to
f7af25f
Compare
Since headers are case-insensitive, this is a bit more robust. Thanks Copilot! Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This begins the clean-room
vercel.stableAPI redesign: a lazy root client now owns transport and lifecycle, and service clients become thin views over that shared runtime instead of each service building its own HTTP/auth stack.In this slice, the stable root surface lands with SDK (
projects,deployments) and cache clients, plus shared stable errors/options/pagination. The genericRequestClientis reduced to transport concerns only, while SDK and cache-specific request policy moves into stable internal clients. Sync and async stay aligned by sharing the same internal backend shape and transport lineage, with tests focused on lazy env resolution, transport reuse, option overlays, and stable error behavior.Reviewer notes
Focus on whether the new ownership boundary is right:
with_options()overlaysEdits
contextContextVar.