fix(pages): declare D1/KV bindings in Pages wrangler.toml - #1025
Conversation
Deploying do-epub-studio with
|
| Latest commit: |
84a5244
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://cb04a9a1.do-epub-studio.pages.dev |
| Branch Preview URL: | https://fix-pages-functions-bindings.do-epub-studio.pages.dev |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
🚀 Performance Report🛠️ CI & Workflow
⚡ Turbo Task Performance
Cache Hit Ratio: 0% (0/7 tasks) 🧪 Test Stability
|
|
✅ Health of changed files: 6.8 → 7.3 (+0.4) 📋 At a glance Files & modules (2)
✅ Health gate: passed 📌 Before you merge
🔎 More signals (2)🔥 Hotspot touched (1)
💀 Dead code (4 findings)
1 more
👀 Suggested reviewers @d-oit 📊 See the full report for this PR |
5289d9d to
56b7e18
Compare
Code Review & Roast — GOAP-253 passVerdict: the binding fix is essential (issue #1014), but the "TEMPORARY diagnostic" code was a live security problem. Stripped in 56b7e18; branch rebased onto current main. 🚨 Must-fix (found, fixed)M1 — Public health endpoint ran admin-login attempts with hardcoded credentials. The diagnostic block in
All of it is gone; the probe is back to the documented ✅ Kept (the actually good parts)
🔧 CI fixes
🧹 Nit pile
|
195cecf to
f8c2af2
Compare
The Pages Functions API served /api/* but had no reachable D1/KV: dashboard deployment_configs bindings were not being attached to Git-integrated builds (DB reads returned 500 INTERNAL_ERROR because env.DB was undefined). Declare the DB/CACHE_KV bindings and app vars in the Pages project's wrangler.toml — the documented mechanism the Git build reads — so the /api/* function gets its bindings on every deploy. Secrets stay in the dashboard. Verified: `wrangler pages dev` now lists env.DB and env.CACHE_KV from this file. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
Report whether env.DB / env.CACHE_KV reached the Pages function so we can confirm D1/KV attach to Git-integrated builds. Removed once verified. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
Surfaces the /api/* 500 root cause in the tail. Removed after login is verified on production. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
Temporary: /api/health now attempts the books/users queries and reports any error message so we can see why DB reads 500 on Pages. Removed after login is verified on production. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
… and health - Add eslint-disable for no-unsafe-assignment on WASM module imports (wrangler CompiledWasm rule types them as any) - Fix no-base-to-string in health.ts by narrowing D1 password_hash to string type before String() calls
Review of this PR found the TEMPORARY diagnostic code crossed security and privacy lines: - /api/health (public) ran a full createAdminSession login attempt with hardcoded credentials against a real admin hash on every request and leaked the first 30 chars of the stored argon2id hash - hardcoded real admin email in three queries (PII in source) - x-diag-* header injection in the Pages Function Restored: - health.ts: dependency-free liveness probe per its own ADR-252 contract - Pages Function: only the functional fix (registerArgon2Wasm before app.fetch); diag headers removed - wrangler.toml: bindings/vars kept; TEMPORARY [observability] block removed CI fixes: - knip dead-code failure: declare functions/api/[[path]].ts as an apps/web ENTRY (was 'ignore'), so its imports into apps/worker are traced and lib/register-argon2-wasm.ts is no longer flagged unused
f8c2af2 to
84a5244
Compare
Problem
The Pages Functions API serves
/api/*but every DB read returns 500 INTERNAL_ERROR —env.DBis undefined at runtime. Dashboarddeployment_configsbindings (set via the Pages API) were not being attached to Git-integrated builds, even after redeploys.Fix
Declare the
DB(D1) andCACHE_KV(KV) bindings plus app vars in the Pages project'swrangler.toml— the documented mechanism the Git build reads. Secrets (SESSION_SIGNING_SECRET,INVITE_TOKEN_SECRET) stay in the dashboard.Verified
wrangler pages devnow listsenv.DBandenv.CACHE_KVfrom this file (previously absent)./api/*function.