Skip to content

fix: quiet the S3 folder-marker warning and make the Picker env vars optional" - #18

Merged
ksprptr merged 4 commits into
prodfrom
dev
Sep 19, 2026
Merged

ksprptr merged 4 commits into
prodfrom
dev

Conversation

@ksprptr

@ksprptr ksprptr commented Sep 19, 2026

Copy link
Copy Markdown
Owner

Before deploying

  • Nothing is required. No env, schema or API contract changes.
  • NEXT_PUBLIC_GOOGLE_API_KEY and NEXT_PUBLIC_GOOGLE_APP_ID were already optional in practice;
    with GOOGLE_ENABLED="false" they can now be dropped from the root .env entirely.

What's in it

  • Creating an S3 folder no longer logs Are you using a Stream of unknown length as the Body of a PutObject request? on every call. The zero-byte prefix marker was written with Body: '', and
    the SDK's content-length middleware guards on if (body && …) — an empty string is falsy, so it
    never set Content-Length, and checkContentLengthHeader then flagged the request as an
    unmeasured stream. Buffer.alloc(0) is truthy with a length of 0, so the header goes out and
    the warning is gone. Dropping Body altogether does not work: undefined is falsy too.
  • The upload path was never the problem — uploadFile has always gone through Upload from
    @aws-sdk/lib-storage, exactly as the warning suggests.
  • openPicker() reads its env first and throws a named error on an empty API key, before
    loading the gapi script and before minting a Picker token. handleManageFolders already funnels
    it through extractApiErrorMessage, so it surfaces as a toast; the message says the variable is
    build-time, because the fix is a rebuild and not a restart.
  • The Picker vars are read in exactly one place, so with Drive switched off nothing reaches
    them: the API omits drive from GET /storage/status and the sidebar's hasDrive never renders
    the entry point. Both .env.example files now say so, the way GOOGLE_ENABLED documents its own
    kill-switch.
  • setAppId stays behind its if (appId) guard, so deployments running without a project
    number keep working.

Verification

  • pnpm build, pnpm lint, 242 unit and 101 e2e pass — unchanged counts: the marker fix
    tightened an existing createFolder test rather than adding one. It asserted only Bucket and
    Key through toMatchObject, so it would not have caught the regression.
  • The warning was reproduced against a closed port (it fires in finalizeRequest, so no S3 is
    needed): Body: '' warns, Body: Buffer.alloc(0) does not, omitting Body warns.
  • A real S3 write was not exercised — Content-Length: 0 is what AWS, MinIO and R2 already expect
    for prefix markers, so only the log line changes.
  • docker compose config with both Picker lines deleted from the root .env resolves them to ""
    and emits no warning; the empty value was traced through the compose default, the Dockerfile
    ARG/ENV, Next's build-time inline and getEnvString, which returns '' for both undefined
    and "".

@ksprptr
ksprptr merged commit 3ae6754 into prod Sep 19, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant