cloudflare / cloudflare/workers-sdk
Secret not found in secret store in local mode
- Dominant language
- TypeScript
- Stars
- 4.5k
- Forks
- 1.5k
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 186
Description
### What versions & operating system are you using?
wrangler 4.16.1, node 22.14.0, Windows 11
### Please provide a link to a minimal reproduction
_No response_
### Describe the Bug
I have a secret in my local secrets store as seen here:
```
wrangler secrets-store secret list 24c5810008074d388f81b2a34e98448f
π Listing secrets... (store-id: 24c5810008074d388f81b2a34e98448f, page: 1, per-page: 10)
βββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββ¬ββββββββββ¬βββββββββ¬ββββββββββ¬ββββββββββββββββββββββββ¬ββββββββββββββββββββββββ
β Name β ID β Comment β Scopes β Status β Created β Modified β
βββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββΌββββββββββΌβββββββββΌββββββββββΌββββββββββββββββββββββββΌββββββββββββββββββββββββ€
β contentful-access-token β adaf5e903ec44232a9f64431dca6ddae β β β active β 5/26/2025, 5:27:16 PM β 5/26/2025, 5:27:16 PM β
βββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββΌββββββββββΌβββββββββΌββββββββββΌββββββββββββββββββββββββΌββββββββββββββββββββββββ€
β contentful-space-id β 9a7df593b71848d49728e3e932144ab7 β β β active β 5/26/2025, 5:27:16 PM β 5/26/2025, 5:27:16 PM β
βββββββββββββββββββββββββββ΄βββββββββββββββββββββββββββββββββββ΄ββββββββββ΄βββββββββ΄ββββββββββ΄ββββββββββββββββββββββββ΄ββββββββββββββββββββββββ
```
and `wrangler.jsonc` contains:
```
"secrets_store_secrets": [
{
"binding": "CONTENTFUL_SPACE_ID",
"store_id": "24c5810008074d388f81b2a34e98448f",
"secret_name": "contentful-space-id"
},
{
"binding": "CONTENTFUL_ACCESS_TOKEN",
"store_id": "24c5810008074d388f81b2a34e98448f",
"secret_name": "contentful-access-token"
}
]
```
However, when accessing the secret in code like this:
```
import { getCloudflareContext } from "@opennextjs/cloudflare";
const context = await getCloudflareContext({ async: true });
const CONTENTFUL_ACCESS_TOKEN = await context.env.CONTENTFUL_ACCESS_TOKEN.get();
```
When building via `opennextjs-cloudflare build`, I receive this error message: `Error: Secret "contentful-access-token" not found` which seems to be emitted from here: https://github.com/cloudflare/workers-sdk/blob/349cffcd547e602a4bf3fb708122cf00bb4ad8d2/packages/miniflare/src/workers/secrets-store/secret.worker.ts#L17
Is this a bug, or am I accessing the secret incorrectly?
### Please provide any relevant error logs
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.