feat(upload-api): wire WRITES_DISABLED env var into context - #636
Merged
Conversation
…text Adds `parseWritesDisabled(env)` to `upload-api/utils.js` (strict `'true'` literal match, matching the `DISABLE_CUSTOMER_REGISTRATION` / `DISABLE_IPNI_PUBLISHING` pattern) and threads `writesDisabled: parseWritesDisabled(process.env)` into the context passed to `createUcantoServer` in `ucan-invocation-router.js`. When `WRITES_DISABLED=true` is set in the upload-api stack's env, the eight user-initiated write capabilities in `@storacha/upload-api` return a `ServiceUnavailable` failure receipt; reads and receipt-side handlers continue to function. Depends on storacha/upload-service#708 merging and a new `@storacha/upload-api` version being published + bumped in this repo's catalog. Until then, this PR's typecheck will flag `writesDisabled` as an unknown field on the context type. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
hannahhoward
force-pushed
the
feat/disable-writes-flag
branch
from
May 15, 2026 08:35
7276632 to
d40ab6b
Compare
hannahhoward
marked this pull request as ready for review
May 15, 2026 08:38
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.
Summary
'true'parseWritesDisabled(env)helper toupload-api/utils.jsand threadswritesDisabled: parseWritesDisabled(process.env)into the context passed tocreateUcantoServerinucan-invocation-router.js.WRITES_DISABLED=truein this stack's env will short-circuit the eight user-initiated write capabilities (space/blob/{add,remove,replicate},space/index/add,upload/{add,remove},store/{add,remove}) with aServiceUnavailablefailure receipt. Reads and receipt-side handlers remain functional.Deliverables
upload-api/utils.jsparseWritesDisabled(env): boolean— strict'true'literal match.upload-api/functions/ucan-invocation-router.jswritesDisabledinto thecreateUcantoServercontext.upload-api/test/utils.test.jsparseWritesDisabled:'true','false','1', empty string, missing — only'true'returns true.Dependency
@storacha/upload-apiversion being published + bumped in this repo's catalog. ThewritesDisabledfield onUcantoServerContextis added by that PR. Until the catalog bump:tscwill flagwritesDisabledas an unknown property on the context. (Other pre-existing typecheck errors in this repo are unrelated.)pnpm install, the typecheck should clear.Operational notes
WRITES_DISABLEDis read once at Lambda cold start; flipping requires a redeploy / process restart.writesDisabled: false→ behavior unchanged.console.warnfrom the upload-service handler (visible in CloudWatch).Test plan
pnpm exec ava --node-arguments='--experimental-fetch' --timeout=60s 'test/utils.test.js'inupload-api/— 6/6 passingpnpm run lintexit 0WRITES_DISABLED=truein staging env, confirmspace/blob/addreturnsServiceUnavailable, reads still work🤖 Generated with Claude Code