8000 fix(cloudflare): add preview IDs for KV, D1, and R2 in wrangler.json by sam-goodwin · Pull Request #413 · sam-goodwin/alchemy · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix(cloudflare): add preview IDs for KV, D1, and R2 in wrangler.json #413

New issue < 8000 details-dialog class="Box Box--overlay d-flex flex-column anim-fade-in fast overflow-auto" aria-label="Sign up for GitHub">

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 18, 2025

Conversation

sam-goodwin
Copy link
Owner

Fixes #411

Handle preview IDs in Wrangler JSON for wrangler dev --remote compatibility:

  • Add preview_id field for KV namespaces that replicates the main namespace ID
  • Add preview_bucket_name field for R2 buckets that replicates the main bucket name
  • Add preview_database_id field for D1 databases that replicates the main database ID

This fixes issues where KV, D1, and R2 throw errors in wrangler dev --remote when preview IDs are not provided in the wrangler.json file.

Since Alchemy doesn’t use environments in the typical Wrangler way, we replicate the main IDs as preview IDs to ensure compatibility.

Generated with Claude Code

Handle preview IDs in Wrangler JSON for `wrangler dev --remote` compatibility:
- Add preview_id field for KV namespaces that replicates the main namespace ID
- Add preview_bucket_name field for R2 buckets that replicates the main bucket name
- Add preview_database_id field for D1 databases that replicates the main database ID

This fixes issues where KV, D1, and R2 throw errors in `wrangler dev --remote` 
when preview IDs are not provided in the wrangler.json file.

Since Alchemy doesn't use environments in the typical Wrangler way, we replicate 
the main IDs as preview IDs to ensure compatibility.

Fixes #411

Co-authored-by: sam <sam-goodwin@users.noreply.github.com>
@sam-goodwin
Copy link
Owner Author

@claude add a test in wrangler.json.test.ts

Copy link
Contributor
claude bot commented Jun 18, 2025

Claude finished @sam-goodwin's task —— View job


Adding test for wrangler.json preview IDs ✅

I've successfully added comprehensive test coverage for the preview ID functionality in wrangler.json.ts.

Todo List:

  • Read the modified wrangler.json.ts to understand the changes
  • Read existing wrangler.json.test.ts to understand test patterns
  • Implement test cases for KV, D1, and R2 preview IDs
  • Run linting and tests
  • Commit changes

Added 4 new test cases:

  1. KV namespace test: Verifies that preview_id matches the main namespace namespaceId
  2. D1 database test: Verifies that preview_database_id matches the main database id
  3. R2 bucket test: Verifies that preview_bucket_name matches the main bucket name
  4. Mixed bindings test: Verifies all three types together to ensure they work correctly in combination

Summary:
✅ All tests passing (4/4)
✅ Biome linting passed with formatting fixes
✅ Changes committed: 12cf8de

The tests ensure that preview IDs are properly replicated from main IDs, providing the compatibility needed for wrangler dev --remote as described in the original PR.


Copy link
pkg-pr-new bot commented Jun 18, 2025

Open in StackBlitz

npm i https://pkg.pr.new/sam-goodwin/alchemy@413

commit: 58a8942

Add comprehensive test coverage for the preview ID functionality in wrangler.json generation:

- KV namespace test: verifies preview_id matches main namespace ID
- D1 database test: verifies preview_database_id matches main database ID  
- R2 bucket test: verifies preview_bucket_name matches main bucket name
- Mixed bindings test: verifies all three types work correctly together

These tests ensure the preview IDs are properly set for `wrangler dev --remote` compatibility.

Co-authored-by: sam <sam-goodwin@users.noreply.github.com>
Copy link
github-actions bot commented Jun 18, 2025

🧹 Website Preview Cleaned Up

The website preview for this PR has been cleaned up as the PR was closed.


🤖 Preview resources have been removed from Cloudflare.

@sam-goodwin sam-goodwin merged commit 4a59d3a into main Jun 18, 2025
4 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.

Handle Preview ID's in Wrangler JSON for Wrangler Dev --remote
1 participant
0