BUG: `evaluate-assessments` Edge Function always returns 500 error from patient app
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 25/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Ferma
- Stack tecnologico
- flutter, supabase
- Ambito
- backend, databases, mobile-dev, security
Direzione di ricerca
Inizia con la Edge Function evaluate-assessments e il percorso di invio degli assessment dell'app del paziente. Esamina come vengono creati il client Supabase e l'header Authorization, quindi controlla l'inserimento in assessment_results e il flusso di autenticazione. Il lavoro è completato quando gli invii autenticati vengono valutati correttamente, il risultato viene salvato per il paziente autenticato e il punteggio viene restituito senza un errore 500.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Is there an existing issue for this?
- I have searched the existing issues
What happened?
This issue and related PR were fully identified and analyzed by myself. Claude was only used to assist with writing descriptions in English.
📌 Issue Overview
The evaluate-assessments Edge Function always returns 500 Internal Server Error when submitting an assessment from the patient app. The root cause is twofold: the Edge Function creates a Supabase client with SUPABASE_ANON_KEY (anonymous role) which is blocked by RLS policies requiring authenticated role, and the Flutter client overrides the Authorization header with the anon key instead of forwarding the user's JWT.
🔍 Steps to Reproduce
- Log in as a patient in the patient app
- Navigate to the Assessments screen
- Select any assessment (e.g., AQ-10)
- Answer all questions and submit
🎯 Expected Behavior
The assessment should be evaluated, the result saved to assessment_results table, and the score returned to the patient.
🚨 Actual Behavior
FunctionException(status: 500, details: {"error":"Internal Server Error"}, reasonPhrase: Internal Server Error)
The Edge Function fails silently because:
- The Supabase client is created at module level with anon key → DB operations are blocked by RLS
- The Flutter client explicitly sets
Authorization: Bearer <SUPABASE_ANON_KEY>, overriding the user's JWT thatsupabase_flutterwould normally send automatically patient_idis taken from the request body instead of the authenticated user's JWT (security issue)- No error handling on the
assessment_resultsinsert operation
💡 Suggested Improvements
- Move Supabase client creation inside the request handler with the user's
Authorizationheader forwarded - Use
supabase.auth.getUser()to extractpatient_idfrom the JWT instead of trusting the request body - Remove the custom
Authorizationheader override in the Flutter client —supabase_flutterautomatically sends the user's JWT viafunctions.invoke() - Add error handling for the
assessment_resultsinsert operation
Improvement PR is ready and waiting for #156 been merged and #157 been resolved.
Record
- I agree to follow this project's Code of Conduct
- I want to work on this issue
- Lingua principale
- Dart
- Stelle
- 30
- Fork
- 49
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Nessuna guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di AOSSIE-Org/NeuroTrack
-
fix(therapist): Method marked @override does not override any inherited methodForse già presa @Muneerali199 l’ha presa 252 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
AOSSIE-Org/NeuroTrack#198 ·
-
fix: Don't use BuildContext across async gaps (use_build_context_synchronously)Forse già presa @Muneerali199 l’ha presa 252 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
AOSSIE-Org/NeuroTrack#197 ·
-
fix(patient): Remove unused and duplicate imports across patient appForse già presa @Muneerali199 l’ha presa 252 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
AOSSIE-Org/NeuroTrack#195 ·
-
BUG: Therapy details save button has no loading guard, allowing duplicate submissions that inflate patient regression reportsForse già presa @Varadraj75 l’ha presa 215 giorni fa. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 68/100
AOSSIE-Org/NeuroTrack#221 ·
-
BUG: Appointment booking ignores selected time slot, every appointment saved at midnight to SupabaseForse già presa @Varadraj75 l’ha presa 220 giorni fa. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
AOSSIE-Org/NeuroTrack#219 ·
Tutte le issue di AOSSIE-Org/NeuroTrack
Issue simili
-
Drop the decision-issue rule from ARCHITECTURE.mdForse già presa @abianche l’ha presa oggi. Apertachore
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 61/100
I maintainer di solito rispondono entro 1 giorno
-
duration: tiny priority: low type: bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
duobaseio/forui#1249 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Off-by-one error in CharacterRange.length excludes end characters ('z', 'Z', '9', 'ÿ')Forse già presa @TimelordLeo l’ha presa oggi. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
I maintainer di solito rispondono entro 2 giorni
-
[Bug] Missing Simplified Chinese translation for 'balance' and 'lowest' balancer outbound namesApertabug from-telegram platform:android version:v5.9.15
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
hiddify/hiddify-app#2655 ·
I maintainer di solito rispondono entro 1 giorno