feat(sdk): filesystem metadata operations (JS + Python) - #224
Open
alitariksahin wants to merge 3 commits into
Open
feat(sdk): filesystem metadata operations (JS + Python)#224alitariksahin wants to merge 3 commits into
alitariksahin wants to merge 3 commits into
Conversation
Client support for the file-metadata endpoints (backend: DX-2944), in both SDKs
so the published surface stays at parity.
- `files.stat(path, { follow })` / `files.stat(path, follow=...)` — returns type
(file/directory/symlink/other), size, mtime, inode, and an opaque `version`
token for optimistic-concurrency guards. Defaults to lstat so a symlink is
reported as such; `follow` dereferences it.
- `files.mkdir(path, { parents })`, `files.rename(from, to)`,
`files.remove(path, { recursive })`.
- `files.read(path, { offset, length })` — bounded byte-range read. The range is
selected by the presence of `length`, not its value, so an explicit length of 0
reads zero bytes instead of falling back to the whole file.
Python mirrors the JS surface (async source of truth, sync client regenerated);
ruff, mypy, the JS<->Python parity gate, and both test suites pass.
Cuts the accumulated Unreleased work as 0.3.0: the filesystem metadata operations added here, plus the previously unreleased browser (Stagehand v4 `act` replay, `tab.run()` removal), recordings download, shallow clone, schedule update, and model-constant changes. Bumps `pyproject.toml` and `upstash_box/_version.py`, promotes the CHANGELOG heading, and records the JS parity point in RELEASE.md. Tagging `python-sdk-v0.3.0` triggers the PyPI release, so that should wait until the backend file-metadata endpoints are in production.
- prettier: reformat box-files.test.ts (JS ci:lint runs `prettier --check`). - ruff B017: assert `ValidationError` instead of a blind `Exception` in the FileStat closed-set test. - ruff I001: sort the test imports. The earlier runs only linted `upstash_box/`, so the test-directory findings and prettier were missed.
There was a problem hiding this comment.
Pull request overview
Adds filesystem metadata operations and ranged reads across the JavaScript and Python SDKs while maintaining API parity.
Changes:
- Adds
stat,mkdir,rename,remove, and rangedread. - Introduces and exports
FileStat. - Updates unit tests, parity documentation, and release metadata.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
.changeset/file-metadata-ops.md |
Records the JavaScript patch release. |
packages/sdk/src/types.ts |
Defines FileStat. |
packages/sdk/src/index.ts |
Exports FileStat. |
packages/sdk/src/client.ts |
Implements the new filesystem APIs. |
packages/sdk/src/__tests__/box-files.test.ts |
Adds JavaScript unit tests. |
packages/python-sdk/upstash_box/types.py |
Defines Python FileStat. |
packages/python-sdk/upstash_box/_version.py |
Bumps the Python version. |
packages/python-sdk/upstash_box/_async/client.py |
Implements async filesystem APIs. |
packages/python-sdk/upstash_box/_sync/client.py |
Mirrors the generated sync APIs. |
packages/python-sdk/upstash_box/__init__.py |
Exports Python FileStat. |
packages/python-sdk/tests/_async/test_box_files.py |
Adds async unit tests. |
packages/python-sdk/RELEASE.md |
Records SDK release parity. |
packages/python-sdk/pyproject.toml |
Bumps the package version. |
packages/python-sdk/PARITY.md |
Documents filesystem API parity. |
packages/python-sdk/CHANGELOG.md |
Documents the Python release. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+168
to
+169
| @respx.mock | ||
| async def test_read_file_range(): |
Comment on lines
+109
to
+110
| describe("files.read range", () => { | ||
| it("sends offset and length for a bounded read", async () => { |
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.
Client support for the filesystem metadata endpoints added in box-backend
#237 (DX-2944), in both SDKs so the
published surface stays at parity.
New methods
TypeScript —
@upstash/boxPython —
upstash-box(async shown; the sync client mirrors it)renameusesfrom_path/to_pathbecausefromis a Python keyword.Semantics
statdefaults to lstat, so a symlink reports assymlink;followdereferences it.versionis an opaque freshness token (inode + sub-second mtime + size) foroptimistic-concurrency guards: re-
statbefore writing and compare for equality.Do not parse it.
length, not its value — an explicitlength: 0reads zero bytes rather than falling back to the whole file. The serverrejects a
lengthabove 8 MiB and 400s malformed/negative range params.removeneedsrecursivefor any directory (rmrefuses directories without-r, empty or not); removing an absent path succeeds.EphemeralBoxpicks all of this up — it sharesbox.files.Example
Testing
tsc+ build clean.regenerated from the async source and regeneration-stable.
15 JS checks, 12 Python async, 6 Python sync — covering mkdir/stat/rename/remove,
lstat vs follow, ranged reads,
length: 0, the 400s, and 404s. An in-placesame-size rewrite produced
…1787156483.243568408-4→…1787156483.536559672-4,confirming the version token detects changes that second-resolution mtime misses.
Release
patch).upstash-boxto 0.3.0 and promotes theCHANGELOG heading. That release also carries the previously unreleased browser
(Stagehand v4
actreplay,tab.run()removal), recordings download, shallow clone,and schedule update work. No tag is pushed here — tagging
python-sdk-v0.3.0iswhat publishes.
Important
Merge and deploy box-backend #237 to production before publishing either SDK —
these methods call endpoints that do not exist there yet.