File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed
Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -64,6 +64,17 @@ export const updateExperiment = onCall(async (request) => {
6464 await AuthGuard . isExperimenter ( request ) ;
6565 const { data} = request ;
6666
67+ // Validate input
68+ const templateId =
69+ data . experimentTemplate ?. id || data . experimentTemplate ?. experiment ?. id ;
70+
71+ if ( ! data . collectionName || ! templateId ) {
72+ throw new HttpsError (
73+ 'invalid-argument' ,
74+ 'collectionName and experimentTemplate.id (or experiment.id) are required' ,
75+ ) ;
76+ }
77+
6778 const experimenterId = request . auth ?. token . email ?. toLowerCase ( ) || '' ;
6879
6980 // Use shared utility to update experiment
@@ -73,7 +84,7 @@ export const updateExperiment = onCall(async (request) => {
7384 const document = app
7485 . firestore ( )
7586 . collection ( data . collectionName )
76- . doc ( data . experimentTemplate . id ) ;
87+ . doc ( templateId ) ;
7788
7889 // If experiment does not exist, return false
7990 const oldExperiment = await document . get ( ) ;
@@ -212,7 +223,7 @@ export const getExperimentTemplate = onCall(async (request) => {
212223 }
213224
214225 const template = createExperimentTemplate ( {
215- id : '' ,
226+ id : data . experimentId ,
216227 experiment,
217228 } ) ;
218229
You can’t perform that action at this time.
0 commit comments