RichardR
Convex Community4mo ago
9 replies
Richard

R2 Environment Variables Issue / Project Structure?

Hello all,

First of all thank you for taking the time to read this, and I am not 100% sure of the cause of this problem, and have spent more hours than I would like to admit hunting down the cause, and I am honestly not too sure.

✖ Error fetching POST  http://127.0.0.1:3210/api/deploy2/start_push 400 Bad Request: InvalidModules: Hit an error while pushing:
Loading the pushed modules encountered the following
    error:
Failed to analyze adapter.js: Uncaught Error: R2 configuration is missing required fields:
Missing: R2_BUCKET, R2_ENDPOINT, R2_ACCESS_KEY_ID, R2_SECRET_ACCESS_KEY
    at parseConfig (../../../../node_modules/@convex-dev/r2/src/client/index.ts:49:20)
    at new R2 (../../../../node_modules/@convex-dev/r2/src/client/index.ts:141:2)
    at <anonymous> (../../services/R2/index.ts:16:1)


Running convex dashboard opens up a dashboard, where the state of the env vars is shown by the attached picture (note all variables are defined)

So for context, my convex project is within a monorepo, and has the following structure (this may / may not be the problem).

├── convex (re-export functions here to maintain a clean generated api structure)
│   ├── _generated
│   ├── convex.config.ts
│   ├── http.ts
│   ├── schema.ts (reexport from resources/schemas, etc)
│   └── tsconfig.json
├── package.json
├── resources (my defined tables, split into schema, queries, mutations files)
├── services (interacting with 3rd parties)
│   └── R2
│       └── index.ts
├── shared
│   ├── errors.ts (frontends use this file)
│   ├── types.ts
│   └── utils.ts (convex-helpers custom queries)
└── tsconfig.json


... (1/2)
CleanShot_2025-09-22_at_13.28.452x.png
Was this page helpful?