fix(miniflare): allow mixed r2Buckets records (#1)#11789
fix(miniflare): allow mixed r2Buckets records (#1)#11789shellscape wants to merge 2 commits intocloudflare:mainfrom
Conversation
* fix(miniflare): allow mixed r2Buckets entries * test(miniflare): strengthen mixed r2Buckets test * test(miniflare): avoid double-fail in r2Buckets test --------- Co-authored-by: CharlieHelps <charlie@charlielabs.ai>
|
|
dropping a comment here to prevent it from going stale |
|
@petebacondarwin thanks, on it. |
# Conflicts: # packages/miniflare/test/index.spec.ts
create-cloudflare
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
|
I've rebased this PR on main, ported the test to vitest style (from ava), and added the missing changeset. Since I don't have push access to your fork, the updated branch is at |
|
Thank you for this contribution! The fix is correct and we'd like to get it merged. Since we weren't able to push the necessary updates (rebase, vitest migration, changeset) to your fork branch, we've moved this to an internal branch and will merge from there. The new PR is linked below. Thanks again for identifying and fixing this issue! |
|
@petebacondarwin im currently on vacation with my family. Thanks for taking this over. I don't see the PR link yet but I'll keep an eye out for it |
|
Yeah sorry I forgot to press "go" on the new PR... |
Fix Miniflare's R2 options validation so
r2Bucketscan be a single record containing mixed entry shapes:string{ id, remoteProxyConnectionString? }Why this change is needed
Miniflare supports both local and remote R2 bindings, and downstream tooling may generate a single
r2Bucketsrecord containing a mix of both shapes.For example, a tool can reasonably create Miniflare options like:
Before this change,
r2Bucketscould be:Record<string, string>), orRecord<string, { id; remoteProxyConnectionString? }>), orstring[])…but a mixed record would fail validation (because Zod would pick one record schema and then reject entries of the other shape). The runtime already normalizes values on a per-entry basis (via
namespaceEntries()), so the stricter validation was blocking a configuration that Miniflare can already interpret correctly.Note: While this work was done with the assistance of @CharlieHelps, it was reviewed and tested locally via package patch by actual humans (me, @shellscape). No slop here.