Fix broken workflows, close security holes, demo-readiness polish - #4
Merged
Conversation
added 5 commits
August 17, 2026 10:25
- PDF export: use headless new — headless: true makes Puppeteer 21 look for chrome-headless-shell, which is never installed, so every export 500d - OAuth callbacks: existing-integration lookups used .single(), which errors once duplicates exist, so every reconnect inserted another copy; use order/limit/maybeSingle instead - Integration sync: demo-mode connections (credentials.demo) now import canned deals so connect->sync->analyze is demonstrable without real CRM credentials; previously demo Salesforce could connect but never sync - Integration sync: a run with zero new records no longer logs as FAILURE - Integration delete: remove SyncLog children first (no DB cascade), so integrations that have synced can actually be deleted - seed.ts: define demoUser — the documented `npm run seed` step crashed on a ReferenceError - semantic_search.sql: add the company_id column the match_proposals function references (live DBs predate company scoping); new storage_bucket.sql sets up the proposal-files bucket + policies - scripts/cleanup-integrations.ts: one-off dedupe + starter templates
- /api/users returned bcrypt password hashes to unauthenticated callers and let anyone create or promote ADMIN users; responses now strip password and mutations are admin-only, with regression tests - /api/files and /api/templates now require auth - Supabase server client prefers SUPABASE_SERVICE_ROLE_KEY when set (keeps the API working once RLS is enabled); documented in .env.example and render.yaml - remove CREDENTIALS.md from the repo (was committed with a shared default password; rotate any credentials that were ever committed)
- fix every unused-import/var, useless-escape and useless-catch warning - real fixes for react-hooks/exhaustive-deps: memoize checkConnection, convert hasShownOfflineWarning to a ref, justify the two intentional navigation-scoped effects inline - scope react-refresh/only-export-components off for shadcn/ui generated components (they export variants alongside components by design) - lint script now fails on any warning so CI keeps the bar
- ARCHITECTURE.md: system diagram and the reasoning behind the split Prisma/PostgREST data access, demo-first auth, AI guardrails, pgvector fallback, and the Render/Docker deployment - docs/DEMO_SCRIPT.md: rehearsed 7-minute storyline with a Q&A cheat sheet - README: setup now matches reality (db push + the two manual SQL files; there are no migration files for migrate deploy to apply) - schema.prisma: declare Proposal.company_id so db push does not drop the column the API and match_proposals rely on
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
End-to-end testing of every API workflow surfaced 7 broken flows and 3 security holes. This PR fixes all of them, cleans lint to zero (now enforced), adds regression tests, and documents the architecture and a demo script.
Broken workflows fixed
headless: truelooks for chrome-headless-shell; useheadless: new(Render/Docker unaffected).single()errors on >1 rows, defeating the upsert; useorder/limit/maybeSinglenpm run seedcrashed on an undefined variable (documented setup step)semantic_search.sqlnow self-contained (addscompany_idit references); newstorage_bucket.sqlfor document uploadSecurity
/api/usersreturned bcrypt password hashes to unauthenticated callers and allowed anyone to create/promote ADMINs — now authed, sanitized, admin-gated, with regression tests/api/filesand/api/templatesnow require authCREDENTIALS.md(shared default password) removed from the repo — rotate anything ever committedSUPABASE_SERVICE_ROLE_KEYwhen set, ready for RLSQuality & docs
--max-warnings 0so CI holds the lineARCHITECTURE.md(system diagram + trade-offs),docs/DEMO_SCRIPT.md, README setup now matches reality (db push+ manual SQL, notmigrate deploy)Verification
Every flow re-tested live after the fixes: create → analyze (Azure OpenAI) → status change → PDF export (200, real PDF) → semantic search (ranked results) → demo CRM sync (3 deals imported, idempotent re-sync) → users endpoint (no hashes).
Post-merge checklist
npx prisma db execute --file prisma/manual/storage_bucket.sqlonce (enables document upload)PRODUCTION_URL/FRONTEND_URLin the Render dashboard